I created Excel VBA code to send emails on a loop through Outlook.
This works with my primary email address. When I change which email address it is sent from to my secondary email address, which is mapped over from Gmail, I receive an error message
This message could not be sent. You do not have the permission to send the message on behalf of the specified user. Error is [0x80070005-0x000004dc-0x00000524].
I cleared the cache, enabled third party apps in Gmail settings, and a few other things without success.
Application.ScreenUpdating = False Dim i As Integer Dim j As Integer i = 3 Do While Cells(i, "A").Value <> "" emailaddress = Cells(i, 1) honorific = Cells(i, 2) lastname = Cells(i, 3) intro = xxx & xxx companytype = Cells(i, 4) firm = Cells(i, 5) customsentence = Cells(i, 6) 'Replace placeholders within email body emailbody = Replace(emailbody, "Var1", xxx) emailbody = Replace(emailbody, "Var2", xxx) emailbody = Replace(emailbody, "Var3", xxx) emailbody = Replace(emailbody, "Var4", xxx) Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) With OutMail .sentonbehalfofname = SendAcct .to = emailaddress .cc = "" .Subject = emailsubjectline .Body = emailbody 'Attachments.Add("") 'Placeholder for future attachments .send**
User contributions licensed under CC BY-SA 3.0