April 2006
Beginner
1114 pages
98h 16m
English
mailitem.Display( )
Displays the email in a message window rather than using the Excel mail composition header. Combining Close and Display allows you to compose custom messages using the Body or HTMLBody properties, as shown here:
Sub SendHTMLEmail( )
' Requires reference to Microsoft Outlook
Dim ws As Worksheet, env As MsoEnvelope, mi As MailItem
' Get the active worksheet.
Set ws = ActiveSheet
' Show email header.
ws.Parent.EnvelopeVisible = True
' Get the MsoEnvelope object
Set env = ws.MailEnvelope
' Get the MailItem object
.
Set mi = env.Item
' Clear the MailItem properties.
ClearMessage mi
' Set MailItem properties.
mi.To = "someone@microsoft.com"
mi.Subject = "Sending HTML emails from Excel"
mi.HTMLBody = "<b>This text using <i>HTML</i> formatting.</b>"
' Close message composition header.
mi.Close olDiscard
' Open in mail message window (gets rid of worksheet).
mi.Display
End SubRead now
Unlock full access