rosaz Posted August 12, 2010 Share Posted August 12, 2010 Hello, I have automated creating an Outlook message and need to add in to specify the Sender's address. However I can't figure out how to reference that field. Here's what I have so far: Local $olMailItem = 0 $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem($olMailItem) With $oOMail .To = "email recipient" .Subject = "subject .Body = "Hello" .Display EndWith Any help is very much appreciated! Thank you!! Link to comment Share on other sites More sharing options...
MrMitchell Posted August 12, 2010 Share Posted August 12, 2010 Try "$oOMail.From" ? Link to comment Share on other sites More sharing options...
seandisanti Posted August 13, 2010 Share Posted August 13, 2010 Try "$oOMail.From" ?I don't have outlook installed on this computer, but if i remember correctly, the From property is read only... in addition to that it looks like you're assigning literal strings where you probably want variables, and you've got the string for the subject line unterminated... Link to comment Share on other sites More sharing options...
MrMitchell Posted August 13, 2010 Share Posted August 13, 2010 I don't have outlook installed on this computer, but if i remember correctly, the From property is read only...Yah you may be right...my Outlook is on Exchange and only one mailbox but in a multi-mailbox setup you can change who the mail sender is. But again, even though it can be changed manually, doesn't mean you'll be able to change it using the Object in a script... I'll install Outlook at home and add two regular mailboxes and see if I can change the sender via script, though I'm sure it's been covered in this forum somewhere already... Link to comment Share on other sites More sharing options...
seandisanti Posted August 13, 2010 Share Posted August 13, 2010 Yah you may be right...my Outlook is on Exchange and only one mailbox but in a multi-mailbox setup you can change who the mail sender is. But again, even though it can be changed manually, doesn't mean you'll be able to change it using the Object in a script... I'll install Outlook at home and add two regular mailboxes and see if I can change the sender via script, though I'm sure it's been covered in this forum somewhere already...in outlook, just press alt+f11 to go into the vba environment, then F2 i believe loads the object viewer. go down and check the properties of mailitem to see the from field. Link to comment Share on other sites More sharing options...
MrMitchell Posted August 13, 2010 Share Posted August 13, 2010 in outlook, just press alt+f11 to go into the vba environment, then F2 i believe loads the object viewer. go down and check the properties of mailitem to see the from field.ok olMailItem has "SenderEmailAddress" and "SenderName" properties but they are read-only.There is also a "SentOnBehalfOfName" and it's not read-only so it should be able to be set, right? Not sure how useful it will be in a non-exchange environment though... Link to comment Share on other sites More sharing options...
seandisanti Posted August 13, 2010 Share Posted August 13, 2010 ok olMailItem has "SenderEmailAddress" and "SenderName" properties but they are read-only.There is also a "SentOnBehalfOfName" and it's not read-only so it should be able to be set, right? Not sure how useful it will be in a non-exchange environment though...in order to be able to actually send from a different address with that field, a delegate has to be setup by that account on the exchange server. Link to comment Share on other sites More sharing options...
MrMitchell Posted August 13, 2010 Share Posted August 13, 2010 in order to be able to actually send from a different address with that field, a delegate has to be setup by that account on the exchange server.Yea and it will still arive as "Sent on behalf of Sender" but not as actually sent FROM Sender. So Rosaz, I think the answer would be NO, can't change sender address using script. Guess you can try to change it via mouse and keyboard control though... Link to comment Share on other sites More sharing options...
seandisanti Posted August 13, 2010 Share Posted August 13, 2010 Yea and it will still arive as "Sent on behalf of Sender" but not as actually sent FROM Sender. So Rosaz, I think the answer would be NO, can't change sender address using script. Guess you can try to change it via mouse and keyboard control though...as long as the account is setup in accounts in outlook, i'm confident that there is a way to do it, but i don't have outlook here to get into the object model to spell it out. go into the object browser and follow the objects down from Application until you find the correct property to set. OR the VBA help file has a fair amount of examples for just about anything, do a search there for creating a new mail item, and it may have the property mentioned in the WITH statement. Or i think you can even start recording a macro, create a new mail message, and then change your from property, then examine the generated macro to get it. Link to comment Share on other sites More sharing options...
MrMitchell Posted August 14, 2010 Share Posted August 14, 2010 Or i think you can even start recording a macro, create a new mail message, and then change your from property, then examine the generated macro to get it.This would make it easier, but I don't think Outlook lets you record macros, unless I'm missing something there too. If you figure out how, please let me know! That would be nice to be able to do... Link to comment Share on other sites More sharing options...
seandisanti Posted August 14, 2010 Share Posted August 14, 2010 This would make it easier, but I don't think Outlook lets you record macros, unless I'm missing something there too. If you figure out how, please let me know! That would be nice to be able to do...it would be under tools>macros>record macro if the functionality is there Link to comment Share on other sites More sharing options...
MrMitchell Posted August 14, 2010 Share Posted August 14, 2010 it would be under tools>macros>record macro if the functionality is thereIn Outlook 2003 it is not available, it is for Word and Excel though. Link to comment Share on other sites More sharing options...
seandisanti Posted August 14, 2010 Share Posted August 14, 2010 In Outlook 2003 it is not available, it is for Word and Excel though.if you have word setup as your defaul email editor, you may be able to start creating a message, then start recording, etc... Link to comment Share on other sites More sharing options...
MrMitchell Posted August 16, 2010 Share Posted August 16, 2010 if you have word setup as your defaul email editor, you may be able to start creating a message, then start recording, etc... Just tried,it's greyed out...bummer Link to comment Share on other sites More sharing options...
Juvigy Posted August 17, 2010 Share Posted August 17, 2010 this works for me: With $oOMail .To = ($to) .SentOnBehalfOfName = ("mail@yahoo.com") .Display EndWith "mail@yahoo.com" is a mailbox i have added in outlook and i have full rights on it. Link to comment Share on other sites More sharing options...
seandisanti Posted August 17, 2010 Share Posted August 17, 2010 nice, i knew it was possible but thought that the behalf was just for delegates. I guess for a non exchange address that should do it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now