Discussion Locked

A SendMail Macro in MS Word???

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I'm trying to set up a small macro in word that will automatically send the documents as an attachment in an Outlook message to a named recipient in my macro. I also want to include a subject line in my macro. I know this can be done with SendMail, but I'm having difficulty setting it up. Can any give me an example to go by?

3 replies

by mg2k

You just need to fill in the blanks for subject, recipient, and attachments.

Sub CallCreateMail()
' This procedure shows how to pass an array of recipients,
' a subject line, a message body, and an array of attachments
' to the CreateMail procedure.
Dim strSubject As String
Dim strBody As String
Dim avarRecip(2) As Variant
Dim avarAttach(2) As Variant

' Create recipients array.
avarRecip(0) =
avarRecip(1) =
avarRecip(2) =

' Create attachments array.
avarAttach(0) =
avarAttach(1) =
avarAttach(2) =

' Create Subject line and message body.
strSubject =
strBody = "

If CreateMail(avarRecip, strSubject, strBody, avarAttach) = True Then
MsgBox "Congratulations! Your mail has been sent."
End If
End Sub

by mg2k

You just need to fill in the blanks for subject, recipient, and attachments.

Sub CallCreateMail()
' This procedure shows how to pass an array of recipients,
' a subject line, a message body, and an array of attachments
' to the CreateMail procedure.
Dim strSubject As String
Dim strBody As String
Dim avarRecip(2) As Variant
Dim avarAttach(2) As Variant

' Create recipients array.
avarRecip(0) =
avarRecip(1) =
avarRecip(2) =

' Create attachments array.
avarAttach(0) =
avarAttach(1) =
avarAttach(2) =

' Create Subject line and message body.
strSubject =
strBody = "

If CreateMail(avarRecip, strSubject, strBody, avarAttach) = True Then
MsgBox "Congratulations! Your mail has been sent."
End If
End Sub

by maribeth_russell

Your answer made sense. However, what if the document I'm placing this macro in is the actual attachment? How do I set up my attachment array to grab that actual document. My apologies - I know very little Visual Basic!

This discussion is closed to new replies.