PDA

View Full Version : Changing sender email address in mailmerge for outlook



tubin
07-10-2019, 10:56 PM
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

gmayor
07-10-2019, 11:31 PM
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.

tubin
07-12-2019, 02:59 AM
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)
24577