More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 25-Nov-2015 22:15

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 ]  
 Outlook and .NET Printer Friendly Version
Writing code with C# and VB.NET to create Outlook add-ins and other projects
VB code to Reply, Select All, Copy, and close an email

I'm trying to code Outlook to Reply, Select All, Copy, then close an email. I can make the below code work perfectly if I don't have the Reply code in the script, when I add the Reply code it stops working.

I'm using this code to quickly copy all contents of a selected email so I can paste into a note record in my work system. I was also hoping to add a line of dashes "------------------------------" between each individual email (header) but that's way above my head.

Any help would be greatly appreciated, here's the code I'm struggling with:

Sub CopyAll_and_openSite()
    Dim objApp
    Dim objInsp
    Dim colCB
    Dim objCBB
    On Error Resume Next
    Set objApp = GetObject("", "Outlook.Application")
    If objApp Is Nothing Then
        Set objApp = Application.CreateObject("Outlook.Application")
    End If
    Set objInsp = objApp.ActiveInspector
    If TypeName(objInsp) = "Nothing" Then
        MsgBox "No inspector window found"
        Exit Sub
        Set colCB = objInsp.CommandBars
        Set objCBB = colCB.FindControl(, 354) ' Reply
        Set objCBB = colCB.FindControl(, 3634) ' clear clipboard
        Set objCBB = colCB.FindControl(, 756) ' select all
        Set objCBB = colCB.FindControl(, 19) ' copy
        Set objCBB = colCB.FindControl(, 2011) ' Close email

    End If

    Set objCBB = Nothing
    Set colCB = Nothing
    Set objInsp = Nothing
End Sub

Thanks again,


  31-Dec-2012  11:11
    Page [ 1 ]