Formatting text with VBA

N

nabhaskaar

Hi I wrote a piece of code as an Excel macro that composes an email an
sends it to a person. But I am not sure how I could format my text i
the body of my email:

How can I bold letters,

How can I add bullets etc..



Can someone offer any help?



Thanks

Bhaskaa
 
K

keepITcool

we're lazy here..



no joke he's the resident excel/outlook/email doctor.


if it's not there.. (can't imagine as it's ultra complete)
i think it may be wise to ask in the outlook newsgroup.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


nabhaskaar wrote :
 
T

TheDuck

Bhaskaar,

It is possible to add formatting to an email sent by VBA but only i
you're willing to use HTML.

Below is something that I created for use where I work and it work
wonderfully well with Excel97 and Outlook 97/98.

Enjoy,

TheDuck

++++++++++++++++++++++++++++++++++++++++++
Sub MailIt()
Dim App As Object
Dim Itm

Dim mailSubject As String
Dim mailSendTo As String
Dim mailCCTo As String
Dim mailText As String
Dim htmlRed As String

htmlRed = "#FF0000"

Set App = CreateObject("Outlook.Application")
Set Itm = App.createitem(0)

'set subject here or reference the contents of a cell
mailSubject = "This is the subject line"

'specify explicitly or reference a cell. If cell contains a list o
recipents then the list must be delimited correctly as Outlook expect
it to be. Same with the CC list
mailSendTo = Cells(3, 2).Text
mailCCTo = Cells(4, 2).Text

'set the body content of the email specifying all relevant HTM
tags
mailText = "<HTML><Body><P>Hi,</P>" _
& "<P>This is a<B><FONT COLOR=" & Chr(34) & htmlRed
Chr(34) & ">" _
& " demonstration</FONT></B> of a formatted email usin
red and bold text</P>" _
& "<P>Regards,</P>" _
& "<P>TheDuck</P></BODY></HTML>"

With Itm
.Subject = mailSubject
.To = mailSendTo
.CC = mailCCTo
.HTMLBody = mailText
'.Display 'this is so the user can see the mail and manuall
hit send
.Send
End With

Set App = Nothing
Set Itm = Nothing
End Su
 
Top