Consulting

Results 1 to 2 of 2

Thread: Solved: Outlook Move Folder Directory

  1. #1
    VBAX Regular
    Joined
    Jul 2007
    Posts
    30
    Location

    Solved: Outlook Move Folder Directory

    I have the below code that works fine, it is running of a rule and will save the excel attachment to a directory. However I cannot get the move message after this has hapened to work, esentially this line

    objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")

    It needs to move it to a folder within a folder.

    Thanks
    [VBA]


    Sub SaveToFolder(MyMail As MailItem)
    Dim strID As String
    Dim objNS As Outlook.NameSpace
    Dim objMail As Outlook.MailItem
    Dim objAtt As Outlook.Attachment
    Dim c As Integer
    Set myDestFolder = myInbox.Folders("Reference")

    'Place path to sav to on next line.
    Const save_path As String = "G:\Gas\Trading Daily Gas Tools\Interruptible User Contract\"

    strID = MyMail.EntryID
    Set objNS = Application.GetNamespace("MAPI")
    Set objMail = objNS.GetItemFromID(strID)

    If objMail.Attachments.Count > 0 Then
    For c = 1 To objMail.Attachments.Count
    Set objAtt = objMail.Attachments(c)
    save_name = Left(objAtt.FileName, Len(objAtt.FileName) - 4)
    'save_name = save_name & Format(objMail.ReceivedTime, "_mm-dd-yyyy_hhmm")
    save_name = save_name & Right(objAtt.FileName, 4)
    objAtt.SaveAsFile save_path & save_name
    Next

    'objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")


    End If
    Set objAtt = Nothing
    Set ApExcel = Nothing
    Set objMail = Nothing
    Set objNS = Nothing

    End Sub
    [/VBA]

  2. #2
    VBAX Contributor
    Joined
    Jul 2009
    Posts
    157
    Location
    I am not sure this is any help but I noticed a couple of things with your code above that may explain the problem, or it could be I do not understand this well enough to help, which is entirely possible.

    The first thing that jumped out at me was the spelling of Interrupible - you may want to make sure that is spelled exactly correctly and has a space preceeding it.

    The second thing that looked odd was that in the code above you have an apostrophe in front of the line:

    [VBA]
    'objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")
    [/VBA]

    Shouldn't it be?:

    [VBA]
    objMail.Move objInboxFolder.Folders("NZRC Interrupible").Folders("2.Processed")
    [/VBA]

    Other than that....I got nothing. Sorry but hope something from the suggestions above help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •