Consulting

Results 1 to 3 of 3

Thread: Changing sender email address in mailmerge for outlook

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Jan 2019
    Posts
    2
    Location

    Exclamation Changing sender email address in mailmerge for outlook

    I need to send invitation to a list of recipient under my boss'es email, whom i got access as 'delegate'
    i tried using VBA to change the sender address when the emails are in outlook 'outbox' , however, I faced <run-time error 438: object doesn't support this property or method>
    below is the code used, can any one help to see where has gone wrong and help me fix it, please?

    ------
    thanks a lot

  2. #2
    You didn't post your code, however, the following should change the sending account to then named account of ALL the mail items in the default outbox
    Sub ChangeAccount()Dim oMail As MailItem
    Dim oAccount As Account
    Dim i As Integer
    Const strAcc As String = "display name of account"
        For Each oAccount In Application.Session.Accounts
            If oAccount.DisplayName = strAcc Then
                For i = Session.GetDefaultFolder(olFolderOutbox).Items.Count To 1 Step -1
                    Set oMail = Session.GetDefaultFolder(olFolderOutbox).Items(i)
                    With oMail
                        .SendUsingAccount = oAccount
                        .Send
                    End With
                Next i
                Exit For
            End If
        Next
        Set oAccount = Nothing
        Set oMail = Nothing
    lbl_Exit:
        Exit Sub
    End Sub
    Or you could use https://www.gmayor.com/ManyToOne.htm in one to one mode and merge to the account of your choice.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    Jan 2019
    Posts
    2
    Location
    thanks gmayor for your help, i will try yours and let you know , below is the one i used (sorry i posted as picture, the forum said the content contain forbidden words, so i can't post as text)
    Capture.jpg

Posting Permissions

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