Jump to content

OutlookEX _OL_ItemRecipientAdd --- Recipient Showing Blank in Variables


Go to solution Solved by SkysLastChance,

Recommended Posts

I am working on a script that looks for a email with specific word in the title. Then it replies back to the email.

This is working as excpected. However, I dont understand why my variable ($vSenderAdd) is coming back empty when I put it into a message box. 

I tried putting it in a array to and still nothing.

I am stuggling to understand why my variable ($vSenderAdd) is working in the _OL_ItemRecipientAdd but not showing when I put it into a variable for a msg box.

Func oOApp_NewMailEx($sOL_EntryId)

    _WinAPI_DeleteObject($hHBmp_BG)
    _GDIPlus_Shutdown()
    GUIDelete()

    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
    Local $vSubject = $oOL_Item.Subject
    Local $vSenderName = $oOL_Item.SenderName



    If StringLeft($vSubject, 5) = 'Hello' Then



        Local $oOL_Sender = $oOL_Item.Sender
        MsgBox(0,"",$oOL_Sender.AddressEntryUserType)
        If $oOL_Sender.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Sender.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then
            Local $vSenderAdd = $oOL_Sender.GetExchangeUser
        Else
            Local $vSenderAdd = $oOL_Item.SenderEmailAddress
        EndIf

        Local $vTextFile = FileOpen(@DesktopDir & "\TempText.txt", 2)

        FileWriteLine($vTextFile, $vSenderAdd)
        FileWriteLine($vTextFile, $vSenderName)
        FileClose($vTextFile)

        MsgBox(0,"Outlook","Recieved E-Mail from " & $vSenderName & @CRLF & $vSenderAdd)
        MsgBox(0,"Exchange",$oOL_Sender.GetExchangeUser)
        Msgbox(0,"Other",$oOL_Item.SenderEmailAddress)
        Msgbox(0,"Variable",$vSenderAdd)
        _ArrayDisplay($vSenderAdd)





        Local $oOutlook = _OL_Open()
        Local $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=I have recived the email")
        $oItem = _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $vSenderAdd)
        $oItem.BodyFormat = $olFormatPlain
        $oItem.GetInspector
        Local $sBody = $oItem.Body
        $oItem.Body = "Thank you! " & StringUpper($vSenderName) & " for your E-mail!" & $sBody
        $oItem.Display


        ;_OL_ItemSend($oOutlook, $oItem)
        ;_OL_Close($oOutlook)

        Exit

    EndIf

EndFunc

So what I can't figure out. Why the email pulls in for this line. ($vSenderAdd)

$oItem = _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $vSenderAdd)

But comes in as blank for all these. ($vSenderAdd)

MsgBox(0,"Outlook","Recieved E-Mail from " & $vSenderName & @CRLF & $vSenderAdd)
        MsgBox(0,"Exchange",$oOL_Sender.GetExchangeUser)
        Msgbox(0,"Other",$oOL_Item.SenderEmailAddress)
        Msgbox(0,"Variable",$vSenderAdd)
        _ArrayDisplay($vSenderAdd)

I know it has something to do with @waters function. I just can't figure it out.

That part that drives me even more crazy is that it was working before. Not sure what I changed exactly. 

Edited by SkysLastChance

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

MsgBox(0,"Exchange",$oOL_Sender.GetExchangeUser)

tries to display an addressentry object.
For all Exchange sender addresses $vSenderAdd is set to this addressentry and hence does not get displayed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...