SkysLastChance Posted September 2, 2022 Share Posted September 2, 2022 (edited) 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. expandcollapse popupFunc 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 September 2, 2022 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
Danp2 Posted September 2, 2022 Share Posted September 2, 2022 Have you tried this? Msgbox(0,"Variable",IsObj($vSenderAdd)) SkysLastChance 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
water Posted September 2, 2022 Share Posted September 2, 2022 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. SkysLastChance 1 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 Link to comment Share on other sites More sharing options...
Solution SkysLastChance Posted September 2, 2022 Author Solution Share Posted September 2, 2022 (edited) Msgbox(0,"Variable",$vSenderAdd.PrimarySmtpAddress) Thank you both. I just needed that little nudge. Edited September 2, 2022 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott 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