FontBold Property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an automation that send an email based on a SQL string in VBA. I want
to format the type face of the email without using HTML. The example is below

strBody = "Meeting Title: " & Format(Me![DateEnter], "Long Date") & vbCr

I am trying to make the meeting title Bold. When the email is produced, all
of the text is standar Arial, 10. How do I recall the font and size in VBA?

Thanks in advance
 
If you are using Outlook to create the email and are setting the Body
property of a MailItem object to your strBody string, I think your out of
luck. For example, I don't think you can format for bold text if you're
doing this:

objMAILITEM.Body = strBody

This is because the Body property only stores plain text.

If you need bold text within the string, I think you have to use the
HTMLBody property (which you've said you don't want to use), as in:

objMAILITEM.HTMLBody = strBody.

In this case, however, strBody needs to contain HTML, not plain text. This
means you have the additional step of converting your formatted text into
HTML, which you can do using Microsoft Word - though it get's pretty messy!

I'd be really glad myself to hear if anyone else has an alternative
solution.

Geoff
 
I'm using myItem (aka MailItem). I'm trying to avoid HTML like the plague.
What if I use RTFBody?

Tom
--
I''m a novice with an advance way of thinking.


Geoff said:
If you are using Outlook to create the email and are setting the Body
property of a MailItem object to your strBody string, I think your out of
luck. For example, I don't think you can format for bold text if you're
doing this:

objMAILITEM.Body = strBody

This is because the Body property only stores plain text.

If you need bold text within the string, I think you have to use the
HTMLBody property (which you've said you don't want to use), as in:

objMAILITEM.HTMLBody = strBody.

In this case, however, strBody needs to contain HTML, not plain text. This
means you have the additional step of converting your formatted text into
HTML, which you can do using Microsoft Word - though it get's pretty messy!

I'd be really glad myself to hear if anyone else has an alternative
solution.

Geoff


Beyuduzz said:
I have an automation that send an email based on a SQL string in VBA. I
want
to format the type face of the email without using HTML. The example is
below

strBody = "Meeting Title: " & Format(Me![DateEnter], "Long Date") & vbCr

I am trying to make the meeting title Bold. When the email is produced,
all
of the text is standar Arial, 10. How do I recall the font and size in
VBA?

Thanks in advance
 
Outlook's Mail Item object does not have an RTFBody property. To
illustrate:

Dim objMI As Outlook.MailItem

' This is illegal:
objMI.RTFBody = strRTFText

' These are legal:
objMI.Body = strASCIIText
objMI.HTMLBody = strHTMLText

Therefore, if you want to format the text in the email, then (as far as I am
aware) the only way to do it is to use HTML.

You don't need to write the HTML yourself. You can get Microsoft Word to do
it for you. However, it takes a lot of effort. So you may feel it's just
not worth it.

This is what you'd need to do using VBA:

1. Open a Word document. (You may find it best to create a Word template
containing the styles you want to use. Then open a blank document based on
that template.)

2. Write and format your text in the Word document. (You'd need to
master Word's Range object to do this. Useful methods are objRNG.Collapse
and objRNG.SetRange. To simplify formatting from VBA, you could apply
styles to ranges objects.)

3. To convert the Word document to HTML text, use the SaveAs method of
the document object as follows:

' Save and close Word doc as HTML:
objDOC.RemovePersonalInformation = True
objDOC.SaveAs strFilePathName, wdFormatFilteredHTML
objDOC.Close

4. Use VBA's "Open" statement to read the ASCII (*.htm) file you just
saved.

Tip: The "Access Developer's Handbook" by Getz, Litwin & Gilbert or the
"Visual Basic Language Developer's Handbook" by Getz & Gilbert contain a
"TextFile" class module, which simplifies the reading of text files.

5. Set the MailItem's HTMLBody property to the text you've just read.

As you see, it's a challenge. But it works reasonably well.

(One niggle: Sometimes bullets are omitted from final paragraphs in the
HTML text if they're not followed by an additional Carriage-Return-Line-Feed
(vbNewLine) character in the Word document. Sometimes bullets are omitted
even when they are followed by vbNewLine!! I haven't gotten to the bottom
of the inconsistency. But this is irrelevant if your text does not contain
automatic paragraph numbering or bullets.)

So, whether it's worth the effort is up to you. You may be lucky! Someone
else might contribute to the Newsgroup with a better method.

Geoff



Beyuduzz said:
I'm using myItem (aka MailItem). I'm trying to avoid HTML like the
plague.
What if I use RTFBody?

Tom
--
I''m a novice with an advance way of thinking.


Geoff said:
If you are using Outlook to create the email and are setting the Body
property of a MailItem object to your strBody string, I think your out of
luck. For example, I don't think you can format for bold text if you're
doing this:

objMAILITEM.Body = strBody

This is because the Body property only stores plain text.

If you need bold text within the string, I think you have to use the
HTMLBody property (which you've said you don't want to use), as in:

objMAILITEM.HTMLBody = strBody.

In this case, however, strBody needs to contain HTML, not plain text.
This
means you have the additional step of converting your formatted text into
HTML, which you can do using Microsoft Word - though it get's pretty
messy!

I'd be really glad myself to hear if anyone else has an alternative
solution.

Geoff


Beyuduzz said:
I have an automation that send an email based on a SQL string in VBA. I
want
to format the type face of the email without using HTML. The example
is
below

strBody = "Meeting Title: " & Format(Me![DateEnter], "Long Date") &
vbCr

I am trying to make the meeting title Bold. When the email is
produced,
all
of the text is standar Arial, 10. How do I recall the font and size in
VBA?

Thanks in advance
 
No way, that is way too much work for a little formating. Thought it would be
simpiler. Oh well. thanks for the help anyway.
--
I''m a novice with an advance way of thinking.


Geoff said:
Outlook's Mail Item object does not have an RTFBody property. To
illustrate:

Dim objMI As Outlook.MailItem

' This is illegal:
objMI.RTFBody = strRTFText

' These are legal:
objMI.Body = strASCIIText
objMI.HTMLBody = strHTMLText

Therefore, if you want to format the text in the email, then (as far as I am
aware) the only way to do it is to use HTML.

You don't need to write the HTML yourself. You can get Microsoft Word to do
it for you. However, it takes a lot of effort. So you may feel it's just
not worth it.

This is what you'd need to do using VBA:

1. Open a Word document. (You may find it best to create a Word template
containing the styles you want to use. Then open a blank document based on
that template.)

2. Write and format your text in the Word document. (You'd need to
master Word's Range object to do this. Useful methods are objRNG.Collapse
and objRNG.SetRange. To simplify formatting from VBA, you could apply
styles to ranges objects.)

3. To convert the Word document to HTML text, use the SaveAs method of
the document object as follows:

' Save and close Word doc as HTML:
objDOC.RemovePersonalInformation = True
objDOC.SaveAs strFilePathName, wdFormatFilteredHTML
objDOC.Close

4. Use VBA's "Open" statement to read the ASCII (*.htm) file you just
saved.

Tip: The "Access Developer's Handbook" by Getz, Litwin & Gilbert or the
"Visual Basic Language Developer's Handbook" by Getz & Gilbert contain a
"TextFile" class module, which simplifies the reading of text files.

5. Set the MailItem's HTMLBody property to the text you've just read.

As you see, it's a challenge. But it works reasonably well.

(One niggle: Sometimes bullets are omitted from final paragraphs in the
HTML text if they're not followed by an additional Carriage-Return-Line-Feed
(vbNewLine) character in the Word document. Sometimes bullets are omitted
even when they are followed by vbNewLine!! I haven't gotten to the bottom
of the inconsistency. But this is irrelevant if your text does not contain
automatic paragraph numbering or bullets.)

So, whether it's worth the effort is up to you. You may be lucky! Someone
else might contribute to the Newsgroup with a better method.

Geoff



Beyuduzz said:
I'm using myItem (aka MailItem). I'm trying to avoid HTML like the
plague.
What if I use RTFBody?

Tom
--
I''m a novice with an advance way of thinking.


Geoff said:
If you are using Outlook to create the email and are setting the Body
property of a MailItem object to your strBody string, I think your out of
luck. For example, I don't think you can format for bold text if you're
doing this:

objMAILITEM.Body = strBody

This is because the Body property only stores plain text.

If you need bold text within the string, I think you have to use the
HTMLBody property (which you've said you don't want to use), as in:

objMAILITEM.HTMLBody = strBody.

In this case, however, strBody needs to contain HTML, not plain text.
This
means you have the additional step of converting your formatted text into
HTML, which you can do using Microsoft Word - though it get's pretty
messy!

I'd be really glad myself to hear if anyone else has an alternative
solution.

Geoff


I have an automation that send an email based on a SQL string in VBA. I
want
to format the type face of the email without using HTML. The example
is
below

strBody = "Meeting Title: " & Format(Me![DateEnter], "Long Date") &
vbCr

I am trying to make the meeting title Bold. When the email is
produced,
all
of the text is standar Arial, 10. How do I recall the font and size in
VBA?

Thanks in advance
 
Back
Top