Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
send to mail recipient ( as Attachment) the email will not send. | Microsoft Word Help | |||
how do i send a email without a send button | Microsoft Word Help | |||
How do i send document via e-mail when send to email is unselectab | Microsoft Word Help | |||
I am attempting to send an email mail merge and word doesn't send | Mailmerge | |||
I cannot use my Send to folder to send email | Mailmerge |