Ligy Posted June 30, 2016 Posted June 30, 2016 Hello everyone. Could you, please, help me with following problem? I need to send an email as different sender. The way "on behalf" does not fit me well enough. Much better for me would be something like declaring account credentials of the email i want to use and then use something like SendUsingAccount, but I am not able to figure out, how to get it from current OutlookEx.au3. Do you have any idea? Thanks a lot. Best Regards, Ligy
water Posted June 30, 2016 Posted June 30, 2016 I just played with the example posted in the wiki using property "SentOnBehalf" and it works pretty well. I use Outlook 2010 on Windows 7. Which version of Outlook do you run? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted June 30, 2016 Author Posted June 30, 2016 Also 2010. I am not able to get it work. Don't know, if it's because some security policies, but when I do it from outlook (new email -> choose different account as from ) it works, when I try to do it via script - "you don't have permission". Second thing - if you do that SentOnBehalf, how it appears to the recipient? Because to me it is appearing like "From: name1 on behalf of name2" and that's not acceptable for me, i really need to have there only the name2
water Posted June 30, 2016 Posted June 30, 2016 (edited) Could you please run example script _OL_AccountGet.au3? If you find the account you want to send from in the displayed array then I've got a working script for you Edited June 30, 2016 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted June 30, 2016 Author Posted June 30, 2016 Row|Col 0|Col 1|Col 2|Col 3|Col 4|Col 5|Col 6|Col 7|Col 8 [0]|1|9||||||| [1]|0|*******|************|*****||*||*****|**.**.**.**** * = my main account So, i suppose the others are missing :/
water Posted June 30, 2016 Posted June 30, 2016 Strange. Only one account in your profile. How do you select "name2" when sending a mail "by hand"? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted June 30, 2016 Author Posted June 30, 2016 Well. It's company email, so maybe there are some security rules, so I am not able to get it externally. But when I start a new email and I click "from" button and choose one of the accounts i have been granted full access (sending emails etc.), I am able to send email as that account.
water Posted June 30, 2016 Posted June 30, 2016 If you select "File > Info" in Outlook how many accounts do you see? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted June 30, 2016 Posted June 30, 2016 So there seems to be another way you access this account (not by your profile). Can you ask your sysadmins how they assign the second user? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted June 30, 2016 Author Posted June 30, 2016 (edited) Ok, so I were able to get more accounts from that AccountGet func. I added whole account to my profile. So now i get more of them. I also found a script for sending from another account: #include "OutlookEX.au3" Global $oOL = _OL_Open() ; Get the list of accounts from your Outlook profile Global $aAccounts = _OL_AccountGet($oOL) ; Create the mail item Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "", "", _ "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.") ; Set the second account object from your profile to send the mails from $oItem.SendUsingAccount = $aAccounts[2][4] ; Add a recipient and resolve it _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Jon Doe") ; Send the mail _OL_ItemSend($oOL, $oItem) ; Close Outlook connection _OL_Close($oOL) Unfortunately i always get this error message: "Variable must be of type "Object".: for the red part. I tried every possible combination of indexes. Any Idea? Edited June 30, 2016 by Ligy
water Posted June 30, 2016 Posted June 30, 2016 Insert some error checking to your script. Something like this: #include "OutlookEX.au3" Global $oOL = _OL_Open() ConsoleWrite("Open: " & @error & "-" & @extended & @CRLF) ; Get the list of accounts from your Outlook profile Global $aAccounts = _OL_AccountGet($oOL) ConsoleWrite("GetAccounts: " & @error & "-" & @extended & @CRLF) ; Create the mail item Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "", "", _ "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.") ConsoleWrite("ItemCreate: " & @error & "-" & @extended & @CRLF) ; Set the second account object from your profile to send the mails from $oItem.SendUsingAccount = $aAccounts[2][4] ConsoleWrite("SendUsingAccount: " & @error & "-" & @extended & @CRLF) ; Add a recipient and resolve it _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Jon Doe") ConsoleWrite("RecipientAdd: " & @error & "-" & @extended & @CRLF) ; Send the mail _OL_ItemSend($oOL, $oItem) ConsoleWrite("Send: " & @error & "-" & @extended & @CRLF) ; Close Outlook connection _OL_Close($oOL) What do you get? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted July 1, 2016 Author Posted July 1, 2016 Open: 0-1 GetAccounts: 0-0 ItemCreate: 1000-0 "C:\path to the file" (125) : ==> Variable must be of type "Object".: $oItem.SendUsingAccount = $aAccounts[2][4] $oItem^ ERROR
water Posted July 1, 2016 Posted July 1, 2016 Can you please post the exact _OL_ItemCreate statement (mask sensitive information). @error = 1000 means: Property does not exist. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted July 1, 2016 Author Posted July 1, 2016 Global $oOutlook = _OL_Open() ConsoleWrite("Open: " & @error & "-" & @extended & @CRLF) Global $aAccounts = _OL_AccountGet($oOutlook) ConsoleWrite("GetAccounts: " & @error & "-" & @extended & @CRLF) Global $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", $eSubject, "BodyFormat=" & $olFormatHTML, $eBody) ConsoleWrite("ItemCreate: " & @error & "-" & @extended & @CRLF)
water Posted July 1, 2016 Posted July 1, 2016 I assume $eSubject and $eBody just contain the Subject and the Body. You need to specify the property to be set with this values. So it schould be: Global $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=" & $eSubject, "BodyFormat=" & $olFormatHTML, "HTMLBody=" & $eBody) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ligy Posted July 1, 2016 Author Posted July 1, 2016 Yep, that was it, how stupid of me. Thank you very much, it's working now. Thanks for all help, I learnt more again. ;-)
water Posted July 2, 2016 Posted July 2, 2016 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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