none
Help with .SaveSentMessageFolder: does not work for some folders RRS feed

  • Question

  • Hello all
    I could use some help with Outlook Macros.

    In Outlook 2010 I(alpha) have access to the folders of another account(beta)
    I send out reports from (beta) to get approvals.

    Alpha(me)

    |-----Inbox
    |-----Afolder

    Beta

    |-----Inbox
    |-----Report1
    |-----Report2

    The code below creates the emails, adds voting buttons and attaches the browsed for reports.
    It also sets the .SaveSentMessageFolder. The issue I have is that the messages cannot be saved to the proper folder on (beta).
    The macro runs with no apparent error but the message is saved to the (alpha) Sent Items folder.
    If I change the path of the .SaveSentMessageFolder to a folder(Afolder) in (alpha) the macro works.
    I have tested the

    batch = "\\beta\Inbox\Report1" 'Save to folder path
    Set folder = GetFolder(batch) 'Get Save to folder object

    with a move instruction and it works both for an email in the (alpha) account and in the (beta) account.
    So I believe I have the correct object.

    I can save to Afolder but not to Report1 or Report2.
    I have also tried

    Set myRecipient = ns.CreateRecipient("beta")
    myRecipient.Resolve
    Set Folder = ns.GetSharedDefaultFolder(myRecipient, olFolderInbox).Folders("Report1")
    Set .SaveSentMessageFolder = Folder

    With the same result. Is there a permissions issue?

    Public Sub HTML_Test() 
        Dim objMsg3 As MailItem 
        Dim folder As Outlook.folder 
        signature = "<pr> </pr> " 
        Set objMsg3 = Application.CreateItem(olMailItem) '  create email
        With objMsg3[INDENT] 
            .To = "" 
            Do While .ReplyRecipients.Count > 0 '  removes current recipients
                .ReplyRecipients.Remove 1 
            Loop 
            .ReplyRecipients.Add "beta" ' Reply To:
            batch = "\\beta\Inbox\Report1" 'Save to folder path
            Set folder = GetFolder(batch) 'Get Save to folder object
            Set .SaveSentMessageFolder = folder 
            .Subject = "" 
            .SentOnBehalfOfName = "beta" 'the From: field
            .BodyFormat = olFormatHTML ' make the format HTML message
            .VotingOptions = "Approve;Approve with Comments;" 
            .HTMLBody = "<p>Hi NPH, <br> <br> </p>" & signature 
            .Display[/INDENT]End With 
            Set objMsg3 = Nothing 
        End Sub 

    Thanks in advance

    Blake

    Sunday, February 16, 2014 5:05 AM

Answers

  • SaveSentMessageFolder property can only be set to a folder in the store where the mailbox is created and sent from.

    If you want to move it to a different store, you can set up an Items.ItemAdd event handler on the primary store's Sent Items folder and move the message explicitly using MailItem.Move.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Proposed as answer by Eugene Astafiev Sunday, February 16, 2014 10:44 AM
    • Marked as answer by Blakearino Sunday, February 16, 2014 3:43 PM
    Sunday, February 16, 2014 5:25 AM

All replies

  • SaveSentMessageFolder property can only be set to a folder in the store where the mailbox is created and sent from.

    If you want to move it to a different store, you can set up an Items.ItemAdd event handler on the primary store's Sent Items folder and move the message explicitly using MailItem.Move.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Proposed as answer by Eugene Astafiev Sunday, February 16, 2014 10:44 AM
    • Marked as answer by Blakearino Sunday, February 16, 2014 3:43 PM
    Sunday, February 16, 2014 5:25 AM
  • Dmitry

        Thanks for the quick reply. I have some more research to do now.

    I have between 30 to 40 reports to send, will using the Items.ItemAdd event handler on every email sent slow Outlook down? I have full disk encryption and it is already slow.

    Blake

    Sunday, February 16, 2014 3:41 PM
  • I don't think that would be too bad, but if you have that many items to send at the same time, you want to make sure that your event handler returns as soon as possible - otherwise future notifications can be dropped.  If your were using a language VB.Net or C#, I'd recommend that you store entry ids of the messages added to the Sent Items folder I to a list and process them later on a timer when you are out of the event handler.

    Or you can create your own special folder (besides Sent Items) in the primary mailbox and set SaveSentMessageFolder to that folder. Since it is your folder, you can simply assume that whatever ends up there needs to be moved to another mailbox later, so you can process the messages there later without relaying on the Items.ItemAdd event handler.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, February 16, 2014 4:48 PM
  • Again, thanks Dmitry.

    I am a non-programmer that goes to the web when I get tired of doing the same thing over and over. What I have to do now is go to Sent folder and move the copies manually back to the proper folders. The code I wrote only does the heavy lifting, I still review them individually and send them one at a time. I would like to try the move from a sub folder back to the proper report folder. Is it better to have 30 folders and an item.add for each or one folder with an item.add that looks at each email and decides where to put them?

    Blake

    Sunday, February 16, 2014 7:16 PM
  • Why do you need 30 separate folders? Wouldn't one custom folder be enough?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, March 3, 2014 6:22 AM