ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a new mail dialog box in Excel using vba (https://www.excelbanter.com/excel-programming/284574-opening-new-mail-dialog-box-excel-using-vba.html)

Michelle

Opening a new mail dialog box in Excel using vba
 
Hi,

I would like to use Excel that runs a macro to open up a
new mail in Outlook. I would also like to put in a
generic body message and subject line, but they would
have to be able to pick who they would like to email it
to as it different everytime. I can only do this if they
were sending the file along with it, but is there anyway
of doing this without attaching the file?

Any help would be much appreciated.

Michelle

Jan Karel Pieterse

Opening a new mail dialog box in Excel using vba
 
Hi Michelle,

I would like to use Excel that runs a macro to open up a
new mail in Outlook.


Like this:

Sub MailIt()
Dim oMailItem As Object
Dim oOLapp As Object
Set oOLapp = CreateObject("Outlook.application")
Set oMailItem = oOLapp.CreateItem(0)
With oMailItem
.To =
.CC =
.Subject = "Your subject goes here"
.Body = "Hi there!"
.Display
End With
Set oOLapp = Nothing
Set oMailItem = Nothing
End Sub


Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


MattShoreson[_6_]

Opening a new mail dialog box in Excel using vba
 

Set OL = CreateObject("Outlook.Application")
Set emlMessage = Outlook.CreateItem(olMailItem)
emlMessage.Attachments.Add "filename"
emlMessage.Subject = "title"
'emlMessage.To = "whoever"
emlMessage.Display

You'll need the outlook reference added via toolsreference in the vb
editor.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements

Michelle To[_2_]

Opening a new mail dialog box in Excel using vba
 
Hi Jan,

Thank you very much for your response.
That's exactly what I want to do!!

Regards,

Michelle

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 08:00 PM.

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