Manipulating the font in a newly created olMailItem???

  • Thread starter cmonroe21 via OfficeKB.com
  • Start date
C

cmonroe21 via OfficeKB.com

I have a form that creates and sends a new MailItem on a button click that
includes the info from the form controls in text in the email body. I need
to figure out how to manipulate the font of this newly created MailItem (an
olMailItem) so that I can get it into a monospace font (I think that's what
it's called... a font where each character takes up the same amount of space)
so that the results look like this:

Date: Date Here
Campus: Campus Here
Trans Type: Trans Type Here
(etc.)

(see, here even the "Date Here" is a little off...)

I tried using vbTab, but it just adds 5 spaces, so the data still does not
line up if it's not a monospace font. I also tried lining them up via spaces
(as you can see in the code below) but again, to have the same number of
spaces so they are on the same space in ever line... not pretty. What's
important is that the data starts on the same space in each line -- that's
how the software I'm sending the message to will extract it -- i.e. the "Date
Here" and "Campus Here" above should start on the same space in the 1st and
2nd lines of the email body. But without a monospace font type it doesn't
look pretty. So, I need to be able to modify the font of the newly created
outgoing MailItem. Got any suggestions?

Here's the code of the command button:

Private Sub cmdSendSub_Click()
'FYI prefix txt denotes a textbox, cmb a combobox
Dim NewEmail As Outlook.MailItem
On Error Resume Next 'do I need this? How does the "Next" work?
Set NewEmail = Application.CreateItem(olMailItem)
NewEmail.To = txtTo.Text
NewEmail.Subject = txtSubject.Text

'Add attachment to email later (NewEmail.Attachments.Add ??)
'...as you can see, my next question will address an attachment :)

'Set font of NewEmail

NewEmail.Body = _
"Date: " & txtDate.Text & vbCrLf & _
"Campus: " & cmbCampus.Text & vbCrLf & _
"Trans Type: " & cmbTransType.Text & vbCrLf & _
"Post Value: " & txtPost.Text & vbCrLf & _
"Adj Value: " & txtAdjustment.Text & vbCrLf & _
"Total: " & txtTotal.Text & vbCrLf
'this doesn't work, to make it pretty either, I just need to use a
monospace font
NewEmail.Send
End Sub

Wow. See, even here they do not line up (they were lined up in the Vba
Editor, which I think uses a monospace font, so I guess the font in this
message box is not a monospace font?). Hmph.
 
D

Dmitry Streblechenko

Use HTMLBody instead of Body - this way you can use any formattign you like
(including tables).

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
C

cmonroe21 via OfficeKB.com

Can I use HTML and not affect the space numbers or line numbers? i.e. if I I
add a bunch of HTML flags, does the first letter show up at line 1 space 1,
from a computer's point of view? It's going to be a computer that will be
extracting the data, starting from a line number and space number, and I
wasn't sure if the HTML coding would throw that off at all???

Dmitry said:
Use HTMLBody instead of Body - this way you can use any formattign you like
(including tables).
I have a form that creates and sends a new MailItem on a button click that
includes the info from the form controls in text in the email body. I
[quoted text clipped - 59 lines]
Editor, which I think uses a monospace font, so I guess the font in this
message box is not a monospace font?). Hmph.
 
D

Dmitry Streblechenko

It all depends on how you format it - try ot experiment with various HTML
layouts and read back the plain text Body property after settign teh HTML.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
cmonroe21 via OfficeKB.com said:
Can I use HTML and not affect the space numbers or line numbers? i.e. if
I I
add a bunch of HTML flags, does the first letter show up at line 1 space
1,
from a computer's point of view? It's going to be a computer that will be
extracting the data, starting from a line number and space number, and I
wasn't sure if the HTML coding would throw that off at all???

Dmitry said:
Use HTMLBody instead of Body - this way you can use any formattign you
like
(including tables).
I have a form that creates and sends a new MailItem on a button click
that
includes the info from the form controls in text in the email body. I
[quoted text clipped - 59 lines]
Editor, which I think uses a monospace font, so I guess the font in this
message box is not a monospace font?). Hmph.
 
C

cmonroe21 via OfficeKB.com

There's more than one HTML layout? I figured if I selected the HTMLBody
instead of Body that is would do whatever default HTML layout that HTMLBody
does, and I wouldn't have a choice? Sorry, I think it's obvious I'm confused!
:(

Dmitry said:
It all depends on how you format it - try ot experiment with various HTML
layouts and read back the plain text Body property after settign teh HTML.
Can I use HTML and not affect the space numbers or line numbers? i.e. if
I I
[quoted text clipped - 14 lines]
 
D

Dmitry Streblechenko

There is a gazillion ways you can create your HTML body (tables, etc) that
looks exactly the same to an end user.
How that will be translated to plain text (Body property), obviously depends
on the original HTML.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
cmonroe21 via OfficeKB.com said:
There's more than one HTML layout? I figured if I selected the HTMLBody
instead of Body that is would do whatever default HTML layout that
HTMLBody
does, and I wouldn't have a choice? Sorry, I think it's obvious I'm
confused!
:(

Dmitry said:
It all depends on how you format it - try ot experiment with various HTML
layouts and read back the plain text Body property after settign teh HTML.
Can I use HTML and not affect the space numbers or line numbers? i.e.
if
I I
[quoted text clipped - 14 lines]
Editor, which I think uses a monospace font, so I guess the font in
this
message box is not a monospace font?). Hmph.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top