![]() |
Writing text to the "read message"
Hi there. I have a project that I have been unable to get help on, so I went
out and bought MS Outlook 2007 Programming the book, and am still having problems :( What I'm doing here is creating an email with a number of fields and controls for the composer to use. The recipient of this email is going to be a computer that can extract data from text in the email message box. So, I need to be able to print the user-selected contents of the controls (via . Value or .Text ???) in text form onto the "read message" email message. The forms are created, I just don't know how to access the Read Message box. Thank you so much! I look forward to hearing from you! |
Writing text to the "read message"
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? -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "cmonroe21" u48566@uwe wrote in message news:8f9973dd2558a@uwe... Hi there. I have a project that I have been unable to get help on, so I went out and bought MS Outlook 2007 Programming the book, and am still having problems :( What I'm doing here is creating an email with a number of fields and controls for the composer to use. The recipient of this email is going to be a computer that can extract data from text in the email message box. So, I need to be able to print the user-selected contents of the controls (via . Value or .Text ???) in text form onto the "read message" email message. The forms are created, I just don't know how to access the Read Message box. Thank you so much! I look forward to hearing from you! |
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.a...g-vba/200901/1 |
Writing text to the "read message"
I'm going to post this as a new thread, too.
cmonroe21 wrote: 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. 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 [quoted text clipped - 14 lines] Thank you so much! I look forward to hearing from you! -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...g-vba/200901/1 |
Writing text to the "read message"
Not quite, you posted this in the same thread as before.
-- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "cmonroe21 via OfficeKB.com" u48566@uwe wrote in message news:8fca76f460b60@uwe... I'm going to post this as a new thread, too. |
Writing text to the "read message"
Plain text is almost impossible to align correctly and unless you're using
WordMail and use the Word object model to format things you can't even access things like font, etc. in a plain text message. For that you'd use Inspector.WordEditor which is a Word.Document object. If it's HTML then you use Inspector.HTMLEditor and that's an IHTMLDocument object and then you'd use syntactically correct HTML to set things. For RTF you really need to be deep into knowing RTF codes so that's not a path I'd take. That's it for the Outlook object model. Probably the best way is to format things as a Word table and use WordMail to get things nicely aligned as you want. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "cmonroe21 via OfficeKB.com" u48566@uwe wrote in message news:8fca171b5f678@uwe... 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. |
Writing text to the "read message"
Thanks so much for your help!
Ken Slovak - [MVP - Outlook] wrote: Plain text is almost impossible to align correctly and unless you're using WordMail and use the Word object model to format things you can't even access things like font, etc. in a plain text message. For that you'd use Inspector.WordEditor which is a Word.Document object. If it's HTML then you use Inspector.HTMLEditor and that's an IHTMLDocument object and then you'd use syntactically correct HTML to set things. For RTF you really need to be deep into knowing RTF codes so that's not a path I'd take. That's it for the Outlook object model. Probably the best way is to format things as a Word table and use WordMail to get things nicely aligned as you want. I bought Microsoft Outlook 2007 Programming. It's a good book, but I needed [quoted text clipped - 54 lines] Wow. See, even here they do not line up (they were lined up in the Vba Editor). Hmph. -- Message posted via http://www.officekb.com |
All times are GMT +1. The time now is 09:16 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com