PDA

Click to See Complete Forum and Search --> : Setting E-mail Recipients


Creekhead
Jan 6th, 2004, 11:59 AM
I have a word document with the following code a command button to save the file and e-mail it. I would like to fill in the e-mail recipients automatically. Is there a simple way to do this?

thanks

ChangeFileOpenDirectory "c:\data\"
ActiveDocument.SaveAs FileName:=SavedFile, _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
ActiveDocument.SendMail

alex_read
Jan 7th, 2004, 02:51 AM
This was taken from the word help files & shows a sample of an E-Mail function which accepts a recipient e-mail address string as a parameter.

I'm not 100% sure on this, but it looks as though this could work for multiple recipients if you pass the string with each address separated as either a ";" or "," character (I think it's the former from memory)...

Using the MsoEnvelope object
Use the MailEnvelope property of the Document object, Chart object or Worksheet object (depending on the application you are using) to return a MsoEnvelope object.

The following example sends the active Microsoft Word document as an e-mail to the e-mail address that you pass to the subroutine.

Sub SendMail(ByVal strRecipient As String)

'Use a With...End With block to reference the MsoEnvelope object.
With Application.ActiveDocument.MailEnvelope

'Add some introductory text before the body of the e-mail.
.Introduction = "Please read this and send me your comments."

'Return a Microsoft Outlook MailItem object that
'you can use to send the document.
With .Item

'All of the mail item settings are saved with the document.
'When you add a recipient to the Recipients collection
'or change other properties, these settings will persist.
.Recipients.Add strRecipient
.Subject = "Here is the document."

'The body of this message will be
'the content of the active document.
.Send
End With
End With
End Sub

zloggins
Jan 31st, 2008, 12:11 PM
Can someone tell me if there is a code to set the priority to high using MailEnvelope