Re: Writing text to the "read message"



I bought Microsoft Outlook 2007 Programming. It's a good book, but I needed
to be able to create a compose message that was a form with text boxes and
comboboxes, and a read message that was a regular email message with the info
from the controls printed in plain text, and it wasn't easy to find the exact
answers I was looking for. But I found MSDN.microsoft.com and was able to
get tons of info pertinent to my project. I've decided to go with the MS Vba
editor rather than using the Outlook script editor, and I've decided to
(instead of messing with the "compose" message vs. "read" message, and the
Message and P.2 tabs) go with a form that sends a MailItem on a command
button click.

BUT... my NEXT question... (you still think you wanna help?!) I need to get
this new MailItem into a basic font so that I can use tabs and have the data
line up nicely. I tried using & vbTab, but it just adds 5 spaces, so the
data is still not very pretty. I also tried lining them up via spaces (as
you can see below) but again, 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), but I also want it to look pretty. So, I
need to get it into, oh I don't know what you call it... a font where each
character takes up the same amount of space. A monospace font? But 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
NewEmail.Send
End Sub


Wow. See, even here they do not line up (they were lined up in the Vba
Editor). Hmph.



Ken Slovak - [MVP - Outlook] wrote:
If this code is running in the form then use Item.Body for the plain text
contents and Item.HTMLBody for any HTML contents (which must be in correct
HTML syntax).

If the code is running in the Outlook VBA project or elsewhere and the email
where you want to place the text is the ActiveInspector then use
Application.ActiveInspector.CurrentItem.Body or .HTMLBody. With standalone
or COM addin code instantiate an Outlook.Application object (in a COM addin
from the trusted Application object that's passed to you) and use that
instead of Application.

Which book did you buy?

Hi there. I have a project that I have been unable to get help on, so I
went
[quoted text clipped - 11 lines]

Thank you so much! I look forward to hearing from you!

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/outlook-prog-vba/200901/1

.