Send E-mail with VBA code from [E-mail Distribution Group] if I have Send as
Good afternoon.
I know that subject of my question is not new, but I can’t find good solution.
I need to send message from the certain E-mail address (E-mail Distribution Group) with VBA code.
I have permission “Send as” and I can do it by hands, changing field “From”,
but I don’t know how to do this in VBA.
There are some methods:
How can I send E-mail with VBA code from [E-mail Distribution Group] if I have “Send as” permission (not using SentOnBehalfOfName property)?
Good afternoon.
I know that subject of my question is not new, but I can’t find good solution.
I need to send message from the certain E-mail address (E-mail Distribution Group) with VBA code.
I have permission “Send as” and I can do it by hands, changing field “From”,
but I don’t know how to do this in VBA.
There are some methods:
- SendUsingAccount doesn't fit because I can’t adjust [Account distribution group] in the [Outlook client] as [Outlook account]. In addition I can send E-mail manually from [Distribution Group] without it.
- SentOnBehalfOfName isn’t correct method, because it changes only SentOnBehalfOfName property, and receiver can see real sender in SenderEmailAddress (SenderName) properties, although I have “Send as” permission.
- SenderEmailAddress (SenderName) could be read only
- Anything else
Code:
Sub CustomMailMessage_111111111111(Item As Outlook.MailItem)
Dim OutApp As Outlook.Application
Set OutApp = CreateObject("Outlook.Application")
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
'Create the message.
Set objOutlookMsg = OutApp.CreateItem(olMailItem)
Set objOutlookRecip = objOutlookMsg.Recipients.Add("Fokin@lgn.ru")
objOutlookRecip.Type = olTo
' objOutlookMsg.SenderEmailAddress = "OBT_Group@XXX.ru"
objOutlookMsg.Subject = "HRU"
'Будем отправлять все письма в HTML иначе приходящие пути к папкам у пользователей не подсвечиваются
objOutlookMsg.HTMLBody = "HRU" & vbCrLf & vbCrLf
objOutlookMsg.Importance = olImportanceHigh 'High importance
'Resolve each Recipient's name.
For Each objOutlookRecip In objOutlookMsg.Recipients
objOutlookRecip.Resolve
Next
objOutlookMsg.Save
objOutlookMsg.Send
Set OutApp = Nothing
End Sub
How can I send E-mail with VBA code from [E-mail Distribution Group] if I have “Send as” permission (not using SentOnBehalfOfName property)?