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
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.
@@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
@@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?
@@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 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.
Check the code here: excelmacroclass.blogspot.com/2024/01/send-google-mail-from-excel-vba-macro.html That line should go inside the With block for CDOmail. With CDOmail .... .Attachment "c:\data\testmail.xlsx" .Send End With
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"
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
Wow, I think I'll stick to Outlook. Thanks for the video.
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
CDOmail.Attachment "c:\data\testmail.xlsx"
@@ExcelMacroMania Thank you for your kind and timely answer
How would one code this using typescript in excel?
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.
@@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
@@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?
@@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
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.
Hi hope you see my message. how to add an attachment to Gmail using a hard-coded path/file name in VBA?
CDOmail.Attachment "c:\data\testmail.xlsx"
Check the code here: excelmacroclass.blogspot.com/2024/01/send-google-mail-from-excel-vba-macro.html
That line should go inside the With block for CDOmail.
With CDOmail
....
.Attachment "c:\data\testmail.xlsx"
.Send
End With
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"
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