Word macro to send an email

P

Pirjo

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 "(e-mail address removed)" _ "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
 
J

Jean-Guy Marcil

Pirjo was telling us:
Pirjo nous racontait que :
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 "(e-mail address removed)" _ "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

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

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Dawn Crosier

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:="(e-mail address removed)")

'If you use Address:="SMTP:[email protected]" 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


--
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 "(e-mail address removed)" _ "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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top