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".
Use SentOnBehalfOfName, and as long as your Exchange account has SendAs permission for the shared mailbox or distribution group, it will be sent from the shared account or group, not sent on behalf of.
If you want to send from another account in your Account list, you'll use SendUsingAccount and select the account by index or by name. See Macros to send message using the default account or a specific account for code samples.
SendAs an address code Sample
Note: this macro is used with Exchange account to send from addresses you have SendAs permissions.
Sub CustomMailMessage() Dim OutApp As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Recipient Dim Recipients As Recipients Set OutApp = CreateObject("Outlook.Application") Set objOutlookMsg = OutApp.CreateItem(olMailItem) Set Recipients = objOutlookMsg.Recipients Set objOutlookRecip = Recipients.Add("firstname.lastname@example.org") objOutlookRecip.Type = 1 objOutlookMsg.SentOnBehalfOfName = "email@example.com" objOutlookMsg.Subject = "Testing this macro" objOutlookMsg.HTMLBody = "Testing this macro" & vbCrLf & vbCrLf 'Resolve each Recipient's name. For Each objOutlookRecip In objOutlookMsg.Recipients objOutlookRecip.Resolve Next 'objOutlookMsg.Send objOutlookMsg.Display Set OutApp = Nothing End Sub