eagle51 Posted December 28, 2007 Posted December 28, 2007 Hallo together, what I want to do: move a specific E-Mail from the outlook default folder to another. e.g. "folder_new". My problem is the move-command for the email. What I found was $Message.Copy. But I don't know how to use this $oOutlook = ObjCreate("Outlook.Application") $oMAPI = $oOutlook.GetNameSpace ("MAPI") $InboxItems = $oMAPI.GetDefaultFolder ($oOutlookFolderInBox).Items ;Read all mails from inbox For $Pos = $InboxItems.Count To 1 Step - 1 $Message = $InboxItems.Item ($Pos) ; If sender = ......... ; HERE THE MOVE-MAIL COMMAND ... Thanks in advance e51
Moderators big_daddy Posted December 29, 2007 Moderators Posted December 29, 2007 You made me finally break down and study the Outlook Object Model. It's not as easy as IE, Word, or Excel, but after a while you get the hang of it.Here is an example that I tested on my Outlook Profile, hopefully it works well for you.expandcollapse popup#include <IE.au3> Global Const $olFolderInbox = 6 $sSender = "someone@somewhere.com" $sNewFolder = "Test Folder" _IEErrorHandlerRegister() $o_Outlook = ObjCreate("Outlook.Application") $oNameSpace = $o_Outlook.GetNameSpace("MAPI") $oInbox = $oNameSpace.GetDefaultFolder($olFolderInbox) $oFolders = $oInbox.Parent.Folders $oNewFolder = 0 For $oFolder In $oFolders If String($oFolder.Name) = $sNewFolder Then $oNewFolder = $oFolder EndIf Next If Not IsObj($oNewFolder) Then $iReturn = MsgBox(4, "Warning", "Folder '" & $sNewFolder & "' was not found." & @CR & @CR & _ "Would you like to create it?") If $iReturn = 6 Then $oNewFolder = $oFolders.Add($sNewFolder) If Not IsObj($oNewFolder) Then MsgBox(64, "Error", "Unable to create the folder '" & $sNewFolder & "'.") Exit EndIf Else Exit EndIf EndIf $oItems = $oInbox.Items For $oItem In $oItems If String($oItem.SenderEmailAddress) = $sSender Then $oItem.Move($oNewFolder) EndIf Next
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