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 / September 2005

Tip: Looking for answers? Try searching our database.

Word macro to send an email

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pirjo - 29 Sep 2005 14:03 GMT
hello

What kind of macro would work to send a document to a specified email
address from Word?
In Excel you have the code:
Sub Send()
ActiveWorksheet.SendMail "firstname.lastname@domain.fi" _ "this is subject"
End Sub

But it does not work in Word (in form ActiveDocument.SendMail)
The ActiveDocument.SendMail part works, but you cannot insert the address
automatically.

Can anyone help, please?

We are talking about Word 2002 on Windows XP
Jean-Guy Marcil - 29 Sep 2005 18:15 GMT
Pirjo was telling us:
Pirjo nous racontait que :

> hello
>
[quoted text clipped - 12 lines]
>
> We are talking about Word 2002 on Windows XP

See
   http://word.mvps.org/faqs/interdev/SendMail.htm

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Dawn Crosier - 29 Sep 2005 18:28 GMT
This might help:

Sub CDOCreateMail()
Dim objCdoSession As MAPI.Session
Dim objNewMsg As MAPI.Message
Dim objOneRecip As Recipient
Dim strDoc As Word.Document

Set strDoc = ActiveDocument
Set objCdoSession = CreateObject("MAPI.Session")
'Logon in to Session entering your mailserver, an
' LineFeed and username.
objCdoSession.Logon "", "", , , , False, "ServerName" & vbLf &
"username"
'Create Email in Outbox
Set objNewMsg = objCdoSession.Outbox.Messages.Add
With objNewMsg
   .Text = "See attached document" & vbCrLf
   .Attachments.Add strDoc
   .Subject = "My Subject"
   'Fields is where you can access numerous properties
   'That you can't access from Outlook's Object Library
   'Plus many that you could
   'For a Deferred Delivery Date
   '.Fields.Add &HF0040, CDate("Oct. 31, 2003 14:00:00")

   'If you want Plain text mail use the Name parameter
   Set objOneRecip =
.Recipients.Add(Name:="dcrosier@foulston.com")

   'If you use Address:="SMTP:me@mail.com" then
   'Outlook sets Recipient to be sent RTF mail only
   'If it doesn't find the recipient in your address
   'book
   'Set objOneRecip = .Recipients.Add(Address:="SMTP:" &
strEmail)

   .Recipients.Resolve
   .Update
   .Send showDialog:=False
End With
Set objNewMsg = Nothing
objCdoSession.Logoff
Set objCdoSession = Nothing
End Sub

Signature

Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.

hello

What kind of macro would work to send a document to a specified
email
address from Word?
In Excel you have the code:
Sub Send()
ActiveWorksheet.SendMail "firstname.lastname@domain.fi" _ "this
is subject"
End Sub

But it does not work in Word (in form ActiveDocument.SendMail)
The ActiveDocument.SendMail part works, but you cannot insert the
address
automatically.

Can anyone help, please?

We are talking about Word 2002 on Windows XP
 
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.