ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatting text with VBA (https://www.excelbanter.com/excel-programming/304804-formatting-text-vba.html)

nabhaskaar

Formatting text with VBA
 
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

--
Message posted from http://www.ExcelForum.com


keepITcool

Formatting text with VBA
 

we're lazy here..

www.rondebruin.nl

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 :

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

How can I bold letters,

How can I add bullets etc..



Can someone offer any help?



Thanks

Bhaskaar


---
Message posted from http://www.ExcelForum.com/



TheDuck

Formatting text with VBA
 
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<PHi,</P" _
& "<PThis is a<B<FONT COLOR=" & Chr(34) & htmlRed
Chr(34) & "" _
& " demonstration</FONT</B of a formatted email usin
red and bold text</P" _
& "<PRegards,</P" _
& "<PTheDuck</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

--
Message posted from http://www.ExcelForum.com


nabhaskaar[_2_]

Formatting text with VBA
 
Thanks a lot

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:21 PM.

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