Jump to content
Ligy

OutlookEx Sending email from different email address

Recommended Posts

Ligy

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

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

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

Share this post


Link to post
Share on other sites
water

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

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 :/

 

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

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.

Share this post


Link to post
Share on other sites
water

If you select "File > Info" in Outlook how many accounts do you see?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

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 by Ligy

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

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

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

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)

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Ligy

Yep, that was it, how stupid of me. Thank you very much, it's working now. Thanks for all help, I learnt more again. ;-)

Share this post


Link to post
Share on other sites
water

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to get the attachments from mails using OutlookEx UDF and then save them in a particular location.
      The UDF considers even the signature images and other images in the mail body as attachments, and saves it in the folder I point. I want only the proper attachment documents to be saved.
      Requesting the guidance of the forum members.
       
       
      Thanks and regards,
      Gowrisankar R.
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to move unread mails from Inbox to a different folder using OutlookEx UDF.
      But its not working for me. I'm not sure what mistake I do.
      I get the error code 6 when the following is executed. From the UDF it is observed that  "No or an invalid item has been specified".
      Note : The UDF version is 1.3.3.1. AutoIt version (v3.3.14.2).
      #include <OutlookEX.au3> Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject", "", 1) If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Could not find a task item in folder 'Outlook-UDF-Test\SourceFolder\Tasks'. @error = " & @error) _ArrayDisplay($aOL_Item, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") _OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Error moving specified task. @error = " & @error) Any help is deeply appreciated. Thanks in advance.
      Thanks and regards,
      Gowrisankar R.
    • bscarano
      By bscarano
      @water
       
      Wondering if you know if the OutlookEx.udf will allow someone to "paste'/"create" a table in an appointment?
      I can add text to the body, but I'd like to all be formatted to look nice for the user.
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.