![]() |
reading the subject line of a new email in outlook 2007
Good Morning All,
I am fairly new to Outlook VBA programming, and suspect that what I am trying to do is fairly novice. I am trying to read the subject, to email address, cc email fields and body of a new email that I am creating before I send it. The button that envokes the macro is embedded in the new email template. I tried the code below to read the subject of the email, but it gave me no results. Any help would be greatly appreciated. Dim oMail As Outlook.MailItem Dim sSubject As String Set oMail = Application.ActiveInspector.CurrentItem sSubject = oMail.Subject MsgBox ("TEST: " & CStr(sSubject)) Cheers, Evan |
reading the subject line of a new email in outlook 2007
So your button is there on a custom Outlook email form? Is it a form type
button that's there? Where is the code executing, is it in the form code? Is your custom form published? If this is running as form code then it is VBScript and not VBA code. That means that you cannot use As clauses and to access the item in the form you use the Item object. So if this is form code the Click handler for that button would look like this: MsgBox ("TEST: " & CStr(Item.Subject) -- 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 wrote in message ... Good Morning All, I am fairly new to Outlook VBA programming, and suspect that what I am trying to do is fairly novice. I am trying to read the subject, to email address, cc email fields and body of a new email that I am creating before I send it. The button that envokes the macro is embedded in the new email template. I tried the code below to read the subject of the email, but it gave me no results. Any help would be greatly appreciated. Dim oMail As Outlook.MailItem Dim sSubject As String Set oMail = Application.ActiveInspector.CurrentItem sSubject = oMail.Subject MsgBox ("TEST: " & CStr(sSubject)) Cheers, Evan |
All times are GMT +1. The time now is 03:46 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