Jump to content
Sign in to follow this  
Zein

OutlookEX keeps email as draft when SentOnBehalfOfName is set.

Recommended Posts

Trying to get this email I send with autoIT to send using a different name than my email, so I looked into the UDF and found the SentOnBehalfOfName tag. 
When I set it, I all the emails I sent through autoit just get saved as drafts. When I remove the flag, it sends emails normally.

Any idea what I'm doing wrong?

 

Func sendLogs($recipientList)
    $oOL = _OL_Open()
    $oItem = _OL_ItemCreate($oOL, $olMailItem, "", "", "Subject=Logs", "BodyFormat=" & $olFormatHTML, "", "SentOnBehalfOfName=Automation")
    For $i = 0 To UBound($recipientList) - 1 Step + 1
        _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $recipientList[$i])
    Next

    $aArray = _FileListToArray($oLOGFolder)
    For $i = 0 To UBound($aArray) - 1 Step +1
        _OL_ItemAttachmentAdd($oOL, $oItem, "default", $oLOGFolder & $aArray[$i])
    Next
    _OL_ItemSend($oOL, $oItem)
    _OL_Close($oOL)
EndFunc

Is how I write it. 

Share this post


Link to post
Share on other sites

Not sure if it matters, but I figured out the error. The issue wasn't with the code, the code was working fine actually. The issue is that Outlook doesn't support using a different display name when sending emails. 

So I switched to using Jos's great SMTP mailer code found here:

And it works like an absolute charm :)

Share this post


Link to post
Share on other sites

Outlook allows to send mails on behalf of another user. You just need to have the required permissions.
Please see the wiki for an example and additional information.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-09-05 - Version 1.5.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...