PDA

View Full Version : Forward Email from shared account and change sender to other account



tbruce
02-10-2019, 11:16 AM
Hi,

I monitor a shared email account for support requests and I'm trying to create a macro that forwards specific emails via a button in the Ribbon to our ticketing system, but when I forward it I need it to come from my primary email account and not the shared account. The code I have works only when I forward an email from my primary account, but when I'm in the shared box, it does not change the sender to my email and instead sends from the shared account name.

Any help with this issue would be much appreciated...




Sub Forward_to_tickets(objMail As Outlook.MailItem)

Dim objForwardMail As Outlook.MailItem
Dim objRecipient As Outlook.Recipient
Dim objMailAccounts As Outlook.Accounts
Dim objMailAccount As Outlook.Account

Set objForwardMail = objMail.Forward
Set objRecipient = objForwardMail.Recipients.Add("<tickets email add>")
objRecipient.Type = olTo
objForwardMail.Recipients.ResolveAll

Set objMailAccounts = Outlook.Application.Session.Accounts
For Each objMailAccount In objMailAccounts
If objMailAccount.DisplayName = "John Doe" Then
objForwardMail.SendUsingAccount = objMailAccount
objForwardMail.Send
End If
Next
End Sub