Sent Mail won't be removed from Draft for Redemption with Outlook 2010

Discussion in 'Microsoft Outlook VBA Programming' started by shawnho, Jun 15, 2012.

  1. shawnho

    shawnho

    Joined:
    Jun 15, 2012
    Messages:
    2
    Likes Received:
    0
    I try to follow the faq to send emails using redemption. I test the code using Outlook 2010 and GMail Pop3/smtp account. I use excel vba to call the outlook object without the active explorer. I notice that if I rem the SafeItem.save, my email would be sent but still stay at the draft folder. The sent one was never moved into the sent folder. After I checking if the sending was successful, the one in the draft folder would be sent again. In the end, I got two identical emails but with a different sent time stamp. Could anyone explain the mechanism?

    I also test the same code on an Outlook 2007 machine but using an Exchange server account. My email simply stays at the draft folder without going anywhere. I try use MAPIUtils.DeliveryNow but still not working. Thanks for pointing out any direction in advance.

    My code is attached below.


    Dim Application As Outlook.Application
    Dim NameSpace As Outlook.NameSpace
    Dim SafeItem, oItem, Utils
    Dim Btn As CommandBarControl
    Dim sRecipient As Variant
    Dim recipient As Outlook.recipient
    Dim Sync As Outlook.SyncObject

    Set Application = CreateObject("Outlook.Application")
    Set NameSpace = Application.GetNamespace("MAPI")
    NameSpace.Logon


    Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
    Set oItem = Application.CreateItem(olMailItem) 'Create a new message
    SafeItem.Item = oItem 'set Item property
    'Set SafeItem.SaveSentMessageFolder = NameSpace.GetDefaultFolder(olFolderSentMail)

    With SafeItem
    For Each sRecipient In Recipients
    Set recipient = .Recipients.Add(sRecipient)
    'recipient.Type = olTo
    Next sRecipient
    'For Each sRecipient In CCTo
    ' Set recipient = SafeItem.Recipients.Add(sRecipient)
    ' recipient.Type = olCC
    'Next sRecipient
    .Recipients.ResolveAll
    .Subject = Subject
    .HTMLBody = SafeItem.Body & Content
    .Save
    '.Display
    .Send
    End With
    ''''''''''''''''''''''''''''''''''''
    ' (1) Use Sync object (this method works for outlook 2010 with gmail pop3 account)
    '''''''''''''''''''''''''''''''''''
    'Sync object
    Set Sync = NameSpace.SyncObjects.Item(1)
    Sync.Start

    Set Application = Null
    Set SafeItem = Nothing
    Set oItem = Nothing
    Set recipient = Nothing
    Set Sync = Nothing
    Set Utils = Nothing
    Set Btn = Nothing
     
    shawnho, Jun 15, 2012
    #1
    1. Advertisements

  2. shawnho

    shawnho

    Joined:
    Jun 15, 2012
    Messages:
    2
    Likes Received:
    0
    Could anyone provide some advices please? I am run out of solutions! :bow:
     
    shawnho, Jun 18, 2012
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page