Send Google Mail From Excel - 3 Different Options
Excel macro/VBA code available in this post: excelmacroclas...
In a previous video we saw how to send an email from Excel (via Outlook) using VBA macros. We have also seen how to send multiple emails in another video. In this video we see how send email via a Google mail or Gmail account, with or without Outlook. Using Outlook follows the process explained in previous videos with a small modification. The second option is using CDO along the mail server settings, which works for Gmail and some other mail providers too. The last option is creating your own Google script API, which only works to send via Gmail but allows to add other functionality.
You can find many other macro examples and Excel VBA learning materials (including the Excel VBA Guide for Beginners) in the blog under the link: excelmacroclas...
And yet, if you want more, you can find various Excel applications of different nature in the other blogs of the Excel Macro Mania saga:
Excel Macro Fun (excelmacrofun....)
Excel Macro Business (excelmacrobusi...)
Excel Macro Sports (excelmacrospor...)
Пікірлер: 15
Wow, I think I'll stick to Outlook. Thanks for the video.
Hi hope you see my message. how to add an attachment to Gmail using a hard-coded path/file name in VBA?
@ExcelMacroMania
4 күн бұрын
CDOmail.Attachment "c:\data\testmail.xlsx"
Hi, this is something i have been trying to replicate. I tried using the second method from your tutorial. But unable to make it work. can you please help? I keep getting the error "Run-time error. The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available"
@ExcelMacroMania
Ай бұрын
Make sure the code is correct, there was a mistake in the video that I corrected later, maybe you didn't watch the whole video. Also, go to your google account and get the exact address of the smtp server (usually is smtp.gmail.com, but can be different). Try with other port (465 vs 25 vs other?). Make sure you have added the right references to the VBA project. There might be some restrictions in your network, etc. You can find the code here: excelmacroclass.blogspot.com/2024/01/send-google-mail-from-excel-vba-macro.html
Could please explain how to add an attachment to gmail when the attachment is defined by a variable and not as hard coded path/filename in VBA. Example .Addattachment "c:\data\testmail.xlsx". I'm looking for something along the lines of .Addattachment path & fname & ".pdf" where both the path and fname are variables defined as strings in the macro. Thank you in advance for your help
@ExcelMacroMania
2 ай бұрын
CDOmail.Attachment "c:\data\testmail.xlsx"
@albertocollazo9986
2 ай бұрын
@@ExcelMacroMania Thank you for your kind and timely answer
How would one code this using typescript in excel?
@ExcelMacroMania
Ай бұрын
I've never used a typescript library for Excel, but there's one for JavaScript. However, I don't know why you want to do that. If you create a macro in Excel use VBA, if you create a web app, use JavaScript or TypeScript or any other.
@proxyhn
Ай бұрын
@@ExcelMacroManiathank you so much It worked! Just another question would you happen to know about how I could format the body text to add images and such
@proxyhn
Ай бұрын
@@ExcelMacroManiasorry for the double comment, I figured out how to use html for images, but how would I set up the “setrequestheader” in the third example?
@ExcelMacroMania
23 күн бұрын
@@proxyhn Here's the HTTP request for the third method (using a Google script/API): With HTTPreq .Open "POST", url, False .setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36" .setRequestHeader "Content-type", "text/plain" .send body End With
i am using an app called mail came in windows 11 how can i send through it regards
@ExcelMacroMania
Ай бұрын
I believe Mail in Windows 11 is Outlook as part of Microsoft 365, so you should be able to send an in email from Excel using the method described in the other videos (Send Mail from Excel) or this one if you manage to setup a gmail account there.