ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Email (https://www.excelbanter.com/excel-programming/328983-email.html)

mburkett

Email
 
Is there a way to have excel not only attach a file to email through a
macro but type the subject and address an email as well Can someone
shoot me some sample code. Thanks - Michael Burkett


sime

Email
 
Hi Michael

Just typed this in off my head. Post if you have any problems getting
this running. My example uses Outlook 98.

Good thing is to set a reference to the Outlook libray through
ToolsReferences and explore the properties and functions through the
Object Library.


Sub quickandnasty()

Dim olApp As Object
Dim eml as Outlook.MailItem
Set olApp = CreateObject("Outlook.Application")

Set eml = olApp.CreateItem(0)

eml.recipients.add "
eml.cc = "
eml.subject = "hi there"
eml.body = "hi there"
eml.send

set olApp = nothing
set eml = nothing

End sub


mburkett wrote:
Is there a way to have excel not only attach a file to email through

a
macro but type the subject and address an email as well Can someone
shoot me some sample code. Thanks - Michael Burkett



sime

Email
 
Sorry, missed one bit of the example:

eml.attachments.add "c:\myfile.txt"



All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com