Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Outlook COM keep default signature


  • Please log in to reply
6 replies to this topic
Xx7
  • Members
  • 674 posts
  • Last active: Mar 24 2015 10:48 PM
  • Joined: 19 Apr 2011

If I use the following, my default signature is removed and the only text in the email is "This is the body".  How can I maintain my default signature?

 

m := ComObjActive("Outlook.Application").CreateItem(0)
m.Subject := "Hi There"        
m.To := [email protected]                  
m.Body := "This is the body"


Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

Found this at MSDN http://msdn.microsof...office.14).aspx
It seems that you need to use a Word Inspector Object to get this done.
 

m := ComObjActive("Outlook.Application").CreateItem(0)
m.Subject := "Hi There"
m.To := "[email protected]"
m.Display
myInspector := m.GetInspector
wdDoc := myInspector.WordEditor
wdRange := wdDoc.Range(0, wdDoc.Characters.Count)
wdRange.InsertBefore("This is the body")

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


ruespe
  • Members
  • 567 posts
  • Last active: Dec 01 2014 07:59 PM
  • Joined: 17 Jun 2008

Nice. Perhaps you can post your solution in http://www.autohotke...k-l/?hl=outlook?



Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Thanks ruespe! I've posted the code there too. :)

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


Xx7
  • Members
  • 674 posts
  • Last active: Mar 24 2015 10:48 PM
  • Joined: 19 Apr 2011

very nice! thanks alot :D



sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
Just a follow-up note on this solution for preserving the Outlook signature.
 
In order to access the WordEditor property, the inspector for the mail item must be the active inspector; if it happens to be the active inspector it should work every time, but it's not a guarantee that it will always be the active inspector.  From here:
 

...you need to wait until the first Inspector.Activate() event for that to be valid usually, before that you get only weak object references.

 
 
I think the safest route to avoiding this problem would be to trigger that activate event every time once the inspector has been obtained.

m :=	ComObjActive("Outlook.Application").CreateItem(0)
m.Subject :=	"Hi There"
m.To :=	"[email protected]"
m.Display
myInspector :=	m.GetInspector, myInspector.Activate
wdDoc :=	myInspector.WordEditor
wdRange :=	wdDoc.Range(0, wdDoc.Characters.Count)
wdRange.InsertBefore("This is the body")
 

gilliduck
  • Members
  • 109 posts
  • Last active: Nov 09 2015 01:07 AM
  • Joined: 19 Dec 2013

Hate to resurrect a dead post, but could use some help. This trick works great except for one thing, it only seems to work with plaintext. I need to replace "This is the body" with a variable and that variable has the body of the email coded with HTML tags. When I replace that text with the variable it posts the body as plain text, HTML tags and all. Is there a way to use this trick and still be able to keep the HTML formatting?

 

 

 

Found this at MSDN http://msdn.microsof...office.14).aspx
It seems that you need to use a Word Inspector Object to get this done.
 

m := ComObjActive("Outlook.Application").CreateItem(0)
m.Subject := "Hi There"
m.To := "[email protected]"
m.Display
myInspector := m.GetInspector
wdDoc := myInspector.WordEditor
wdRange := wdDoc.Range(0, wdDoc.Characters.Count)
wdRange.InsertBefore("This is the body")