Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Swindon, Wiltshire, United Kingdom
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change the From address in Outlook (Access 2003)

    I'm trying to change the From address in a process that automatically sends e-mails from Access.

    The From address will depend on the record being used to generate the e-mail.

    I can't seem to find the right method in the Outlook 2003 Object model that will allow me to do this.

    A variable is declared as follows:

    Dim olkMailingMessage As Outlook.MailItem

    Then later on a reference to an e-mail is set:

    Set olkMailingMessage = appOutlook.CreateItem(olMailItem)

    I would have expected there to be a method related to the mail item (olkMailingMessage) that would allow the From address to be changed but I just can't seem to find anything. Perusing the Outlook object model has been pretty fruitless too!

    If this is possible then it would save my sanity to know where abouts in the Object Model I should be - I seem to have spent a lot of time not being able to find the vital information for what should be just 1 line of code.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change the From address in Outlook (Access 2003)

    You cannot change the From address for security reasons. You can specify the SentOnBehalfOfName instead. The recipient(s) will see

    From <you> on behalf of <SentOnBehalfOf>

    If you're on Exchange Server, you need the appropriate permissions to do this. Example:

    olkMailingMessage.SentOnBehalfOfName = "Bill Gates"

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Swindon, Wiltshire, United Kingdom
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change the From address in Outlook (Access 2003)

    Thanks Hans,

    I suspected that there would not be a method to allow it but clung to the possibility that I may just be missing something.

    Hopefully using the SentOnBehalfOfName method will be okay - the reply to address is correct to this shouldn't be a major issue.

    Thanks again.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Change the From address in Outlook (Access 2003)

    Another useful option is to set the Reply To address. So even though the email comes from a particular individual, you can make replies go to someone else. Often this is what you want to happen anyway.
    Do it with this:
    <pre> Set oMail = oOutl.CreateItem(olMailItem)
    With oMail
    With .ReplyRecipients.Add("whomever@wherever.com.au") 'Replies get sent here
    If Not .Resolve Then
    'Should always check for probable invalid email address
    </pre>


    For emails that you don't want to receive replies to (for unmonitored mailing lists for example), set the reply address to one that doesn't exist, such as bounce@domain.com.
    Peter

  5. #5
    Lounger
    Join Date
    Jan 2001
    Location
    Swindon, Wiltshire, United Kingdom
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change the From address in Outlook (Access 2003)

    Thanks Peter,

    I have the reply address set to the required address but the client wanted the from address to appear the same.

Posting Permissions

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