PDA

View Full Version : From DDL field



esherr77
08-26-2016, 11:26 AM
Hi Friends
I am currently putting a macro together to send emails , but theyre all shown as comming from my personal email instad of the group I belong to withing the company, does anybody know a piece of code in order to change this?
Thanks in advance.

mancubus
08-26-2016, 01:30 PM
?
https://social.msdn.microsoft.com/Forums/en-US/93b936f0-1fa3-455a-831c-f2b3d025c896/sendmail-function-in-vba-exceloutlook?forum=isvvba

esherr77
08-29-2016, 07:18 AM
Thank you for the reply, yet I cant seem to find where to put the from field.

mancubus
08-30-2016, 02:18 AM
i have been using this for years...
adopt it to your requirements!



Sub vbax_56977_send_mail_on_behalf()

With CreateObject("Outlook.Application")
With .CreateItem(olMailItem)
.SentOnBehalfOfName = "MailAddressOfTheDesiredSender" 'put group mail address here. you must be authorized to send emails on behalf of this mail address. contact IT where needed.
.To = "MailTO@mail.com"
.CC = "MailCC@mail.com"
.BCC = "MailBCC@mail.com"
.Subject = "....." 'Subject here
.Body = "....." 'Msg Body here
.Attachments.Add "FullPath\File1Name"
.Attachments.Add "FullPath\File2Name"
'.Display 'to display the message
'.Send 'to send the message
End With
End With

End Sub

snb
08-30-2016, 02:24 AM
@Manc


With CreateObject("Outlook.Application").CreateItem(0)

suffices. ;)

mancubus
08-30-2016, 05:17 AM
yes.

but copying-pasting an existing procedure is easier than modifying it.

:devil2: