convert Outlook VBA code to add-in

I have some working VBA code for an Outlook macro. What if any procedures are available to convert that to an add-in to Outlook with the minimum amount of re-programing. Are there conversion tools that would help?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Convert VBA to VB. Fairly straightforward. Create an Outlook add-in using the SDK. Place your logic in the shell app.
You will have to address distribution and security of course

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lineonecorpAuthor Commented:
Thanks for the quick response. When you say 'Place your logic in the shell app.' is that a cut-and-paste operation?
Yes, but depending on your logic you will want to leverage the logic required by the plugin logic especially around communication. You will have to split and tune your code for the new environment.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

lineonecorpAuthor Commented:
It doesn't sound so cut-and-paste.  Can you give me a few examples of the kind of  'logic' that I might employ that would require a lot of re-working?
Not seeing what your VBA does makes that difficult. If most of your logic is internal to your program and doesn't require a lot of calls to built in VBA functions then you are pretty well set.
Create an Outlook plugin using Visual Studio and the SDK and you will see the stub functions that should be populated to interact with Outlook as a plugin.

lineonecorpAuthor Commented:
Code follows. Perhaps you could point out whether it would be cut-and-paste or not and if not what is it in the code that renders it not cut-and-paste.

Dim WithEvents colInsp As Outlook.Inspectors
Private Sub Application_Startup()
    Set colInsp = Application.Inspectors
End Sub
Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
    Dim msg As Outlook.MailItem
    Dim mymsg As String
    Dim myResult As Integer
    Dim count As Integer
    On Error Resume Next
    If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
        Set msg = Inspector.CurrentItem
        If msg.Size = 0 Then
            If msg.Recipients.count > 1 Then
                mymsg = "Do you really want to reply to all original recipients?"
                myResult = MsgBox(mymsg, vbYesNo, "Flame Protector")
                If myResult = vbNo Then
                    StripExternal msg
                End If
            End If
        End If
        Set msg = Nothing
    End If
End Sub
Sub StripExternal(olkMsg As Outlook.MailItem)
    Const INTERNAL_DOMAIN = ""
    Dim olkRcp As Outlook.Recipient, intIndex As Integer
    For intIndex = olkMsg.Recipients.count To 1 Step -1
        Set olkRcp = olkMsg.Recipients.Item(intIndex)
        Select Case olkRcp.AddressEntry.AddressEntryUserType
            Case olSmtpAddressEntry
                If InStr(1, LCase(olkRcp.Address), INTERNAL_DOMAIN, vbTextCompare) = 0 Then
                End If
            Case olExchangeUserAddressEntry
                If InStr(1, olkRcp.Address, INTERNAL_X400, vbTextCompare) = 0 Then
                End If
            Case olExchangeDistributionListAddressEntry, olOutlookDistributionListAddressEntry
            Case Else
                MsgBox "The message contains an unusual address type that cannot be processed.", vbExclamation + vbOKOnly, "Strip External"
        End Select
End Sub
Sub DisplayX400()
    Dim olkMsg As Outlook.MailItem, olkRcp As Outlook.Recipient
    Set olkMsg = Application.ActiveInspector.CurrentItem
    For Each olkRcp In olkMsg.Recipients
        MsgBox olkRcp.Address
    Set olkMsg = Nothing
    Set olkRcp = Nothing
End Sub

lineonecorpAuthor Commented:
Still responding?
you will have to look for the assemblies corresponding to Outlook objects you use.
MailItem, Recepient. The object structures may be different so you will likely have to tune your code a bit to use the new object interfaces. It looks straightforward and a bit of looking at the SDK will be helpful to show you which assemblies you will need. There are also some VBA to .Net converts out there that will take care of most of the grunt work.
lineonecorpAuthor Commented:
Expert did not answer question asked.  I think the Expert was trying so I am leaving the points. However, I received nothing of value from this Exchange.
Some parts you will be able to cut and paste but my point is that the VBA objects will not map exactly to the .NET objects. There are porting tools some of which are free that will do some of the dirty work but you will still need to bring your code in line with the interfaces/objects offered by .net
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.