Auto Forward Outlook 'Sent' Items for Backup

August 6, 2008 10:04 by Ramana

This is third time I'm searching net for Auto BCC from Outlook. Whenever I change my laptop I forget to take the VBA script backup, and search the net again to cook the code as I need. This time I thought of posting to blog so that in future if needed i can pick it faster as well it helps lot other.

kick it on DotNetKicks.com

When I send an email I want a copy to be on GMail, in case if I change my PST or have to search quickly on my sent emails or to keep a backup copy or even to check whether my outlook and Norton have delivered it correctly. Sometimes Nortorn Outbound Email Scanning service won't resolve DNS properly and shows error. If we have sent 2 or 3 mails you won't know which one is delivered and which one is not. So to be on safer side GMail helps me.

VBA Code

Private Sub Application_ItemSend(ByVal MyMail As Object, Status As Boolean)
    Dim objEmails As Recipient
    Dim intRes As Integer
    Dim strBcc As String

    '''' Your Bcc address ''''
    strBcc = "my.sent.item@gmail.com"

    On Error Resume Next

    Set objEmails = MyMail.Recipients.Add(strBcc)
    objEmails.Type = olBCC
    If Not objEmails.Resolve Then
        intRes = MsgBox("Could not able to resolve Bcc address. Do you want to still deliever the message?", vbYesNo + vbDefaultButton1, "Could Not Resolve Bcc Recipient")
        If intRes = vbNo Then
            Status = True
        End If
    End If

    Set objEmails = Nothing
End Sub

Outlook Configuration 

  1. In Outlook open the VBA editor by pressing Alt+F11 or Tools -> Macro -> Visual Basic Editor 
  2. Open the ThisOutlookSession module, by double clicking on it.
  3. Copy the above code and paste it into ThisOutlookSession module
  4. Change the Bcc email address in the code
  5. Save it
  6. Now we need to generate the Digital Certificate:
    • Click the Start button -> All Programs -> Microsoft Office -> Microsoft Office Tools, -> Digital Certificate for VBA Projects.
    • In the your certificate's name box, type a descriptive name for the certificate.
    • When the certificate confirmation message appears, click OK.


  7. To verify the certificate in the Personal Certificates store:
    • Open Windows Internet Explorer.
    • Click on the Tools menu -> Internet Options, -> Content tab -> Certificates -> Personal tab.
    • You will find recently created certificate here


  8. Switch back to Outlook VBA editor (if closed press Alt+F11 in Outlook)
  9. Click on ThisOutlookSession module
  10. Click on the Tools menu -> Digital Signature
  11. Choose the certificate and click Ok
  12. Close the VBA Editor
  13. Close the Outlook it may ask again for saving, click Yes


  14. Reopen the Outlook, while opening it will prompt the 'Microsoft Office Outlook Security Notice'


  15. Click on 'Trust all documents from this publisher' 

That's it! It works smoothly. If you change the code, don't forget to re-apply the Digital Signature. If you like to test or troubleshoot in VBA Editor keep a bookmark (red dot) against a line in the code and send a test mail. Outlook will come to that point and wait. Next press F8 or F5 to continue further. Click on breakpoint (red dot) again to remove the same.

Happy forwarding!!!

 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

Mavan August 12. 2008 02:10
Nice post, it helped thanks Mavan
|
Mavan

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

December 4. 2008 02:47
|