Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Shazza Shazza is offline
external usenet poster
 
Posts: 34
Default using a macro so send an email

Hi I have created an electronic form that i want filed out online. Once the
form is completed, I would like it to be emailed directly back to me. I have
tried to create a macro that will open up the email address bar and insert my
address into it then send but the macro wont run. When i get to the end of
the form the address bar just keeps opening up and waiting for someone to
type in and email address. Is there something i am missing here or is it
just not possible
--
Thank you for reading my post. Hopefully you can answer my querie
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default using a macro so send an email

See http://www.word.mvps.org/FAQs/InterDev/SendMail.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Shazza wrote:
Hi I have created an electronic form that i want filed out online.
Once the form is completed, I would like it to be emailed directly
back to me. I have tried to create a macro that will open up the
email address bar and insert my address into it then send but the
macro wont run. When i get to the end of the form the address bar
just keeps opening up and waiting for someone to type in and email
address. Is there something i am missing here or is it just not
possible



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default using a macro so send an email

the following will send the current document to " as
an attachment. Change that to your return e-mail address. Change the subject
and body text also. The document is sent straight to the Outbox of Outlook
and either sent immediately or when the user sends it according to the
user's Outlook settings.

Sub Send_As_Mail_Attachment()

' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next
'Prompt the user to save the document
ActiveDocument.Save
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "
.Subject = "This is the subject"
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
.Body = "Returned Form"
.Send
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Shazza wrote:
Hi I have created an electronic form that i want filed out online.
Once the form is completed, I would like it to be emailed directly
back to me. I have tried to create a macro that will open up the
email address bar and insert my address into it then send but the
macro wont run. When i get to the end of the form the address bar
just keeps opening up and waiting for someone to type in and email
address. Is there something i am missing here or is it just not
possible



  #4   Report Post  
Posted to microsoft.public.word.docmanagement
danhattan danhattan is offline
external usenet poster
 
Posts: 30
Default using a macro so send an email

Hi Graham.

This looked really cool and like something I could add to existing macros,
so I copied and pasted it into the VB editor and attempted to run it.
However, I get the following compile error: User-defined type not defined. In
the editor it has highlighted the statement Dim oOutlookApp As
Outlook.Application.

Any idea why it's returning this error? If it helps, my Outlook is currently
running.

Dan

"Graham Mayor" wrote:

the following will send the current document to " as
an attachment. Change that to your return e-mail address. Change the subject
and body text also. The document is sent straight to the Outbox of Outlook
and either sent immediately or when the user sends it according to the
user's Outlook settings.

Sub Send_As_Mail_Attachment()

' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next
'Prompt the user to save the document
ActiveDocument.Save
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "
.Subject = "This is the subject"
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
.Body = "Returned Form"
.Send
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Shazza wrote:
Hi I have created an electronic form that i want filed out online.
Once the form is completed, I would like it to be emailed directly
back to me. I have tried to create a macro that will open up the
email address bar and insert my address into it then send but the
macro wont run. When i get to the end of the form the address bar
just keeps opening up and waiting for someone to type in and email
address. Is there something i am missing here or is it just not
possible




  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default using a macro so send an email

To use things from the Outlook programming environment, you have to
set a reference to the Outlook library. Open your macro in the VBA
editor, go to Tools References, and check the box next to "Microsoft
Outlook 11.0 Object Library".

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 17 Jul 2007 13:34:03 -0700, danhattan
wrote:

Hi Graham.

This looked really cool and like something I could add to existing macros,
so I copied and pasted it into the VB editor and attempted to run it.
However, I get the following compile error: User-defined type not defined. In
the editor it has highlighted the statement Dim oOutlookApp As
Outlook.Application.

Any idea why it's returning this error? If it helps, my Outlook is currently
running.

Dan

"Graham Mayor" wrote:

the following will send the current document to " as
an attachment. Change that to your return e-mail address. Change the subject
and body text also. The document is sent straight to the Outbox of Outlook
and either sent immediately or when the user sends it according to the
user's Outlook settings.

Sub Send_As_Mail_Attachment()

' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next
'Prompt the user to save the document
ActiveDocument.Save
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "
.Subject = "This is the subject"
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
.Body = "Returned Form"
.Send
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Shazza wrote:
Hi I have created an electronic form that i want filed out online.
Once the form is completed, I would like it to be emailed directly
back to me. I have tried to create a macro that will open up the
email address bar and insert my address into it then send but the
macro wont run. When i get to the end of the form the address bar
just keeps opening up and waiting for someone to type in and email
address. Is there something i am missing here or is it just not
possible






  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default using a macro so send an email

Oops - I was forgetting that the Outlook library was not installed by
default

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Jay Freedman wrote:
To use things from the Outlook programming environment, you have to
set a reference to the Outlook library. Open your macro in the VBA
editor, go to Tools References, and check the box next to "Microsoft
Outlook 11.0 Object Library".


Hi Graham.

This looked really cool and like something I could add to existing
macros, so I copied and pasted it into the VB editor and attempted
to run it. However, I get the following compile error: User-defined
type not defined. In the editor it has highlighted the statement Dim
oOutlookApp As Outlook.Application.

Any idea why it's returning this error? If it helps, my Outlook is
currently running.

Dan

"Graham Mayor" wrote:

the following will send the current document to
" as an attachment. Change that to your
return e-mail address. Change the subject and body text also. The
document is sent straight to the Outbox of Outlook and either sent
immediately or when the user sends it according to the user's
Outlook settings.

Sub Send_As_Mail_Attachment()

' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next
'Prompt the user to save the document
ActiveDocument.Save
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "
.Subject = "This is the subject"
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
.Body = "Returned Form"
.Send
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Shazza wrote:
Hi I have created an electronic form that i want filed out online.
Once the form is completed, I would like it to be emailed directly
back to me. I have tried to create a macro that will open up the
email address bar and insert my address into it then send but the
macro wont run. When i get to the end of the form the address bar
just keeps opening up and waiting for someone to type in and email
address. Is there something i am missing here or is it just not
possible



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
danhattan danhattan is offline
external usenet poster
 
Posts: 30
Default using a macro so send an email

That did the trick. Thanks much for the help.

"Jay Freedman" wrote:

To use things from the Outlook programming environment, you have to
set a reference to the Outlook library. Open your macro in the VBA
editor, go to Tools References, and check the box next to "Microsoft
Outlook 11.0 Object Library".

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 17 Jul 2007 13:34:03 -0700, danhattan
wrote:

Hi Graham.

This looked really cool and like something I could add to existing macros,
so I copied and pasted it into the VB editor and attempted to run it.
However, I get the following compile error: User-defined type not defined. In
the editor it has highlighted the statement Dim oOutlookApp As
Outlook.Application.

Any idea why it's returning this error? If it helps, my Outlook is currently
running.

Dan

"Graham Mayor" wrote:

the following will send the current document to " as
an attachment. Change that to your return e-mail address. Change the subject
and body text also. The document is sent straight to the Outbox of Outlook
and either sent immediately or when the user sends it according to the
user's Outlook settings.

Sub Send_As_Mail_Attachment()

' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next
'Prompt the user to save the document
ActiveDocument.Save
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "
.Subject = "This is the subject"
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
.Body = "Returned Form"
.Send
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Shazza wrote:
Hi I have created an electronic form that i want filed out online.
Once the form is completed, I would like it to be emailed directly
back to me. I have tried to create a macro that will open up the
email address bar and insert my address into it then send but the
macro wont run. When i get to the end of the form the address bar
just keeps opening up and waiting for someone to type in and email
address. Is there something i am missing here or is it just not
possible




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
send to mail recipient ( as Attachment) the email will not send. [email protected] Microsoft Word Help 4 May 30th 07 02:11 PM
how do i send a email without a send button Panic!atthedisco Microsoft Word Help 1 April 21st 07 03:54 AM
How do i send document via e-mail when send to email is unselectab brenda's office works Microsoft Word Help 1 March 30th 07 06:01 PM
I am attempting to send an email mail merge and word doesn't send Tom Mailmerge 3 November 21st 05 09:28 PM
I cannot use my Send to folder to send email rannie Mailmerge 0 February 26th 05 04:39 AM


All times are GMT +1. The time now is 06:43 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"