TechGuise
asked on
Autofill Subject and Body of an Outlook MSG that is already open.
I have a program that opens a new OUTLOOK msg, attaches a file and inserts the appropriate "TO" email address. The user then has to manually type the SUBJECT and BODY (which is the same for each email.
I would like to create a MACRO that enters this text for them and tie it to a toolbar button.
I found the attached code on EE (for the life of me I can't find it again to refer to), that creates a new msg from scratch.
What I'm trying to do is figure out the code that would take a msg that is already started (and open) and simply type in some predefined text for the SUBJECT and BODY.
I just can't get it to work with a msg that is already open. Can anyone point me in the right direction?
A really awesome "extra" would be that the static text would be kept somewhere (instead of the VBA code) that the user could easily update. Like maybe an appropriately named CONTACT or something.
Thanks
CreateEmailMsg.txt
I would like to create a MACRO that enters this text for them and tie it to a toolbar button.
I found the attached code on EE (for the life of me I can't find it again to refer to), that creates a new msg from scratch.
What I'm trying to do is figure out the code that would take a msg that is already started (and open) and simply type in some predefined text for the SUBJECT and BODY.
I just can't get it to work with a msg that is already open. Can anyone point me in the right direction?
A really awesome "extra" would be that the static text would be kept somewhere (instead of the VBA code) that the user could easily update. Like maybe an appropriately named CONTACT or something.
Thanks
CreateEmailMsg.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Chris, that works GREAT! Any ideas on storing the text somewhere for easier updating?
You could scale the script up to read from a text file or such but it wouldn't really be much different from storing it as a variable in the same script
Dim strSubject
Dim strBody
strSubject = "Fred"
strBody = "Doris" & vbCrLf & vbCrLf & _
"I am sending you this greeting!" & vbCrLf & vbCrLf & _
"Luv Me"
With CreateObject("outlook.application")
If .inspectors.Count > 0 Then
With .activeinspector.currentitem
.Subject = strSubject
.body = strBody
End With
End If
End With
Chris