Outlook COM - change FROM

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Outlook COM - change FROM

22 Jun 2017, 08:10

Hi, I want to change email adress from my own to noreply when I'm creating a new email via Outlook but can't find how to do that. Can someone help me?

I have tried this one. Sounds good, doesn't work.

Code: Select all

m := ComObjActive("Outlook.Application").CreateItem(0)
m.Subject := "New email"
m.To := ""
m.From := "[email protected]"
m.Display
m.BodyFormat := 2 ; olFormatHTML
myInspector := m.GetInspector
wdDoc := myInspector.WordEditor
wdRange := wdDoc.Range(0, wdDoc.Characters.Count)
m.HTMLBody := Body
wdRange.Font.Name := "Calibri"
wdRange.Font.Size := "11"
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Outlook COM - change FROM

22 Jun 2017, 09:44

This seemed to work when I briefly tested it just now.

Code: Select all

while m.ReplyRecipients.Count > 0
    m.ReplyRecipients.Remove(1)

m.ReplyRecipients.Add("[email protected]")
Reference used: https://stackoverflow.com/questions/925 ... 30#9259830

HTH :)
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: Outlook COM - change FROM

23 Jun 2017, 01:19

kon wrote:This seemed to work when I briefly tested it just now.

Code: Select all

while m.ReplyRecipients.Count > 0
    m.ReplyRecipients.Remove(1)

m.ReplyRecipients.Add("[email protected]")
Reference used: https://stackoverflow.com/questions/925 ... 30#9259830

HTH :)
hm.. I have tried this one but it doesn't work.. Can you share your code which works for you?

this is mine:

Code: Select all

m := ComObjActive("Outlook.Application").CreateItem(0)
m.Subject := "Test"
m.To := ""
while m.ReplyRecipients.Count > 0
    m.ReplyRecipients.Remove(1)
m.ReplyRecipients.Add("[email protected]")
m.Display
m.BodyFormat := 2 ; olFormatHTML
myInspector := m.GetInspector
wdDoc := myInspector.WordEditor
wdRange := wdDoc.Range(0, wdDoc.Characters.Count)
m.HTMLBody := Body
wdRange.Font.Name := "Calibri"
wdRange.Font.Size := "11"
return
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Outlook COM - change FROM

23 Jun 2017, 07:57

euras wrote:hm.. I have tried this one but it doesn't work..
I don't know then.
euras wrote:Can you share your code which works for you?
I already did.
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: Outlook COM - change FROM

28 Jun 2017, 02:51

well, no'one of those works with my code. I'm using Outlook 2016, but I even can't get the value of "From" section. So no one of those lines actually works.. Maybe someone knows how to change the default address to other in FROM section in new email in Outlook?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus, songdg and 260 guests