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.
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.