Results 1 to 3 of 3

Thread: Setting E-mail Recipients

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    US
    Posts
    1

    Question Setting E-mail Recipients

    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

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    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.
    VB Code:
    1. Sub SendMail(ByVal strRecipient As String)
    2.  
    3.     'Use a With...End With block to reference the MsoEnvelope object.
    4.     With Application.ActiveDocument.MailEnvelope
    5.  
    6.         'Add some introductory text before the body of the e-mail.
    7.         .Introduction = "Please read this and send me your comments."
    8.  
    9.         'Return a Microsoft Outlook MailItem object that
    10.         'you can use to send the document.
    11.         With .Item
    12.  
    13.             'All of the mail item settings are saved with the document.
    14.             'When you add a recipient to the Recipients collection
    15.             'or change other properties, these settings will persist.
    16.             .Recipients.Add strRecipient
    17.             .Subject = "Here is the document."
    18.  
    19.             'The body of this message will be
    20.             'the content of the active document.
    21.             .Send
    22.         End With
    23.     End With
    24. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Lively Member
    Join Date
    Jan 2008
    Posts
    66

    Re: Setting E-mail Recipients

    Can someone tell me if there is a code to set the priority to high using MailEnvelope

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width