Baraoic Posted August 29, 2008 Share Posted August 29, 2008 Wondering if its possible to have a script open an accounts exchange's mail box and scan the inbox for an email from a specific person then copy part of the body to an array? I searched to forums for hours and closest thing I found was http://www.autoitscript.com/forum/index.ph...amp;hl=exchange hrz999 said he was able to search the inbox for a message. I am not that great at autoit, but it looks just like the top and bottom part of his code is just the _INetSmtpMailCom to send email. The middle section of his code looks like it searches for a message but im not sure what it does and his comments are in a different language. Any help would be appreciated. Link to comment Share on other sites More sharing options...
Baraoic Posted August 30, 2008 Author Share Posted August 30, 2008 Nothing? Link to comment Share on other sites More sharing options...
Zedna Posted August 30, 2008 Share Posted August 30, 2008 Search forum for: ObjCreate("Outlook.Application") There are more examples. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Baraoic Posted September 3, 2008 Author Share Posted September 3, 2008 Search forum for: ObjCreate("Outlook.Application") There are more examples. Ok thanks I looked up about that after reading the help file on COM and MSDN on the outlook COM functions i think I understand how it works. Now I have a problem that I have no idea what is causing it. Here is my code so far: $Outlook = @ProgramFilesDir & "\Microsoft Office\OFFICE11\OUTLOOK.EXE" If Not FileExists($Outlook) Then MsgBox(0, "Error", "Can't Find Outlook") Exit EndIf $Pass = InputBox("Password", "Please enter the password.", "", "*M", 190, 115) If @error = 1 Then Exit EndIf RunAs("name", "domain", $Pass, 1, $Outlook) Sleep("5000") $objOutlook = ObjGet("", "Outlook.Application") $objNameSpace = $objOutlook.GetNamespace("MAPI") $objFolder = $objNamespace.GetDefaultFolder(6) $numItems = $objFolder.Items.Count $L = 0 $M = 1 For $L = 1 To $numItems $objMessage = $objFolder.Items($M) $Subject = $objMessage.Subject() $Body = $objMessage.Body() If $Subject = "test" Then $objMessage.Delete $L = $numItems Else $M = $M + 1 EndIf Next MsgBox(0, "Body", $Body) now i have a computer that's on the domain but stays logged on locally. I wanted it to open outlook as a user on the domain which works fine in the code but what happens is it errors at getnamespace and says Variable must be of type "Object". I took out the runas and the objget and down works on its own, but once i have it runas it gives that error for some reason. I even opened outlook through runas and then ran from objget and down and it worked just when its all together that it errors out and I cant figure it out. Any suggestions of what it could be and thanks. Link to comment Share on other sites More sharing options...
Baraoic Posted September 4, 2008 Author Share Posted September 4, 2008 Ok I did some further testing and found out that the error code is 800401E3 which means Operation unavailable. Found some info on it about it from http://www.autoitscript.com/forum/index.php?showtopic=10444 relating to internet explorer, but nothing from outlook. Also I found out that after I open outlook from the runas and pause for a few seconds to let it open and alt tab to have a different window selected it works fine. Anyways that's what I am gonna do as a workaround just though I would say that for the next person that has the same problem. Link to comment Share on other sites More sharing options...
Baraoic Posted September 12, 2008 Author Share Posted September 12, 2008 Just though I'd post what i found out. I don't know if its our domain or not but apparently you cant have the script rerun itself with a users credentials, but having script 1 run script 2 with a different users credentials will work. Also if you have a script run say outlook from runas to get a different users mailbox then if you use objget it will cause a com error, but if you say alt tab or anything to have a different window selected then it wont give the error. It must have something to do with the objget trying to get the current users outlook, but not sure why when you change windows after you open the other users outlook and change windows why it will then work. 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