Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Sending Email from Word 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob W - 08 Dec 2007 16:14 GMT
Greetings,

I am wanting to send a questionnaire via word (It must keep its formatting
as is full of list box and other controls), so I recorded the macro of using
the word 2007 option to send email

ActiveDocument.SendMail

I then want to add a subject, recipients and even a message would be a nice
bonus! Which I dont think is supported via .SendMail

I googl'd around and found

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

The first method roundslip doesnt appear to work as error appears ..

Run-time error '5892';
Method 'HasRoutingSlip' of object '_Document' failed.

The second method cant be applied due to the formattign issue, plus Im sure
it could be done simpler.

Any advice or assistance would be appreciated.

Cheers
Rob W
Rob W - 08 Dec 2007 18:01 GMT
I should also add Outlook Express is my DEFAULT emailer.

Seems this causes issues with objMailItem

Cheers
Rob

> Greetings,
>
[quoted text clipped - 23 lines]
> Cheers
> Rob W
Rob W - 08 Dec 2007 20:34 GMT
I found some example code on the web, however the message "user defined type
not define appears on line "oOutlookApp As Outlook.Application"

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
   MsgBox "Document needs to be saved first"
   Exit Sub
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
   Set oOutlookApp = CreateObject("Outlook.Application")
   bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
   .To = "recipient@mail.com"
   .Subject = "New subject"
   'Add the document as an attachment, you can use the .displayname
property
   'to set the description that's used in the message
   .Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
     DisplayName:="Document as attachment"
   .Send
End With

If bStarted Then
   oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

>I should also add Outlook Express is my DEFAULT emailer.
>
[quoted text clipped - 30 lines]
>> Cheers
>> Rob W
Graham Mayor - 09 Dec 2007 06:55 GMT
See the reply in vba beginners - and please do not multi-post.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

> I found some example code on the web, however the message "user
> defined type not define appears on line "oOutlookApp As
[quoted text clipped - 70 lines]
>>> Cheers
>>> Rob W
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.