Jump to content

[SOLVED] Having issues moving an email to a folder under another accounts inbox


Recommended Posts

Morning, I am having trouble moving emails to a folder under another account's inbox. 

Here is the code I have tried so far. 

 

; Access the Need Human folder under HELPDESK email account
    Local $nhFolder = _OL_FolderAccess($oOutlook, "helpdesk@hotmail.com\Inbox\Need Human")
    If @error <> 0 Then Exit MsgBox(16, "GC_WO_BOT:", "Error accessing folder 'helpdesk@hotmail.com\Inbox\Need Human'. @error = " & @error & " at line: " & @ScriptLineNumber)

    ;_ArrayDisplay($nhFolder, "Folder Access")
    ;MsgBox("", "email", $aItems[1][0])

    
    ; Move the E-mails
    _OL_ItemMove($oOutlook, $aItems[1][0], Default, $nhFolder[5], "Need Human")
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove", "Error moving specified Email. @error = " & @error & ", @extended = " & @extended & " at line: " & @ScriptLineNumber)
    ConsoleWrite("The current email " & $aItems[1][0] & "was just moved to: " & $nhFolder[1] & @CRLF)

I get error moving specified email @error = 1, @extended = 1 

Edited by nooneclose
Link to comment
Share on other sites

I figured it out, Here is the final working code.

Func MoveSkippedMail()

    ConsoleWrite("Sub-Action 4: Move the Skipped E-mails" & " at line: " & @ScriptLineNumber & @CRLF)
    ConsoleWrite("The current email's subject was just changed. 'Processed' has been added." & "at line: " & @ScriptLineNumber & @CRLF)

    ; Access the Need Human folder under HELPDESK email account
    Local $nhFolder = _OL_FolderAccess($oOutlook, "helpdesk@hotmail.com\Inbox\Need Human")
    If @error <> 0 Then Exit MsgBox(16, "GC_WO_BOT:", "Error accessing folder 'helpdesk@hotmail.com\Inbox\'. @error = " & @error & " at line: " & @ScriptLineNumber)

    ;_ArrayDisplay($nhFolder, "Folder Access")
    ;MsgBox("", "email", $aItems[1][0])

    ; Move the E-mails
    _OL_ItemMove($oOutlook, $aItems[1][0], Default, $nhFolder[1])
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove", "Error moving specified Email. @error = " & @error & ", @extended = " & @extended & " at line: " & @ScriptLineNumber)
    ConsoleWrite("The current email " & $aItems[1][0] & "was just moved to: " & $nhFolder[1] & @CRLF)

    ConsoleWrite("Action 15: Finished" & " at line: " & @ScriptLineNumber & @CRLF)
EndFunc

 

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

×
×
  • Create New...