Click here to Skip to main content
13,290,729 members (74,700 online)
Click here to Skip to main content
Add your own
alternative version


45 bookmarked
Posted 1 Dec 2006

Solutions to Common Issues encountered during Outlook Add-in development.

Rate this:
Please Sign up or sign in to vote.
Discusses solutions to some of the common issues encountered during Outlook Add-In development.


In this article I intend to share some of the common issues encountered during Outlook Add-in (VSTO) development and how these may be addressed. There is interesting information available out there on the web that would help out the VSTO community and I have also tried to provide the links to these articles.

Common Issues

Is there a simpler way to add Prerequisites for VSTO through VS2005?

In an earlier article Walkthrough - Automatic Update Process for Outlook Add-in Solutions, I had discussed setting up the prerequisites through the Launch Conditions Editor. This may be a time-consuming process and may have to be repeated for other VSTO projects.

I found some interesting information here on how you can achieve it by selecting the VSTO pre-requisites directly in your Setup project. You only have to do it once and it makes life easier.

Read the instructions in file 'InstallNotes.txt' that is included as part of this download on how to set it up on your development machine. Once installed, in VS2005 you have to right click the 'VSTO Setup' project and selected 'Properties'. Click on the 'Prerequisites' button that would pop-up something similar to the screen shot shown below.

Prerequisites for VSTO

Click here to download Visual Studio Tools for Office runtime (vstor.exe).
Click here to download Office 2003 Primary Interop Assemblies (PIA) redistributable (O2003PIA.exe).

How do I Sign an Assembly prior to deployment in VS2005?

Your VSTO application needs to be signed with a strong name prior to deployment. To sign the assembly in VS2005, follow these steps:

  • Right-click your VSTO project and under Properties, select the Signing option.
  • Choose New and provide the key file name accordingly.
  • Uncheck the box that protects the key file with a password.

    Signing Assembly

How do I manually setup code access security (CAS) policy?

Once you have the .msi file generated from your VSTO Setup project, you are all set to install your solution. But you still need to consider what permissions your application requires on the end user machine and this is where CAS policy comes in.

For more information of setting up CAS at the User, Machine and Enterprise levels, refer to the article in this link.

To set up CAS for your application at the "User level", follow these steps:

  • Open Control Panel -> Administrative Tools.
  • Click on Microsoft .NET Framework 2.0 Configuration.
  • Open up Runtime Security Policy node.
  • Open the User policy node.
  • Open the Code Groups folder.
  • Right-Click All_Code group and click New.
  • Enter the Name and Description of your new code group as show below and click Next.

    Create CAS Group

  • Select Strong Name as the appropriate membership condition from the drop down and click on the Import button to retrieve the strong name from the assembly from the location the application was installed.
  • Do not set the Version of the assembly and click Next.
    Note: The procedure to "Sign an Assembly" has been discussed earlier in this article.

    Import public key

  • Select Full Trust as the permission set to your code group.

    CAS permission

    Note: This needs to be handled as part of the installation whereby you need to accomplish the equivalent of running Caspol.exe with no user intervention. Something close to this objective is discussed in the following section.

How do I programmatically configure CAS as part of Installation?

I found a sample code (available in both C# and VB.NET) published here, which may be used to handle CAS programmatically. The author has excellently handled both Install and UnInstall in his code.

Follow these steps:

  • In your VS2005 Solution, add a new Class Library project.
  • Delete the default Class1.cs file created.
  • Add a new Installer Class (SetSecurity.cs)

    Add installer

  • Cut/paste the relevant code from sample into SetSecurity.cs that you just created.
    Note: You will have to include the following 3 namespaces in the SetSecurity.cs class (which were missing)
    using System.Security;
    using System.Security.Policy;
    using System.Security.Permissions;
  • Configure the PolicyLevel and PermissionSet in the code to your needs.
    private readonly string installPolicyLevel = "Machine";
    private readonly string namedPermissionSet = "FullTrust";
  • In the Outlook Setup project, the Primary output from SetSecurity project needs to be included and using the Custom Actions Editor you may add it as a Custom Action for Install and UnInstall as shown below.

    Custom Editor for Security

  • Build the Outlook Setup project (which references both your security project and Outlook Add-in project) and Install them on the End-User machine. A snapshot of the Code Access Security (CAS) entry in the .NET Framework 2.0 Configuration is shown below.

    Result CAS

Why is the URL to the deployment server missing in the Manifest file?

A concern normally raised by the user community is that the Manifest file on the .msi installed machine does not have any reference to the published URL. There is a roundabout way to handle this.

Follow these steps:

  • In the screen-shot below, the next version of the release during a Publish in the below Outlook Add-in project would be

    Publish version

  • Right-Click the Outlook Add-in project and do a Publish to some deployment server. Refresh the project and look for a manifest file inside the bin\Release\xxx.publish\xxx_2.0.0.8 folder (where 'xxx' is your Outlook Add-in project name).
  • Open up the manifest file and you would notice that "codebase" has the "complete URL" to the deployment server. This is the one that finally needs to show up in the end user machine.

    Manifest in Bin folder

  • Notice that the setup project shown below has the Primary output from both MyOutlookAddin and SetSecurity projects. We need to exclude the manifest file from the primary output of the Outlook Add-in.
  • Right-click on the Primary Output from Outlook Add-in and select Exclude Filter.

    Exclude Filter

  • Click on Add Filter to exclude the manifest file shown in the primary output.

    Exclude Filter result

  • You now have to manually add the right manifest from the bin folder that was published. Right click on the Setup project and select Add followed by File.

    Add Setup file

  • Navigate to bin\Release\xxx.publish\xxx_2.0.0.8 folder and select the recently published manifest and add it to the project. Open the manifest file to confirm that the URL to the published server exists in the manifest as shown below.

    File Add result

  • Rebuild your setup solution and install it on the end user machine.


The objective of writing this article was to share the information I gathered from both experience and reading what the experts out there had to say, so as to provide a helping hand to the VSTO community.

</strong />This way of setting up CAS is good enough for the application to run on one machine. Unfortunately, we cannot expect all end-users to manually set up the CAS for your Outlook Add-in assembly. </strong />


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Sanjeev Thazhathaveetil
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Questiondo you know of any outlook ad-on developers? Pin
Member 788177828-Apr-11 14:04
memberMember 788177828-Apr-11 14:04 
QuestionAddIn fails to load with manually added (published) manifest Pin
Klemens Kanal14-Aug-07 3:37
memberKlemens Kanal14-Aug-07 3:37 
QuestionHow to get body of new arrived email. Pin
Shashi Shinde1-Mar-07 19:30
memberShashi Shinde1-Mar-07 19:30 
QuestionStep 5: Fails to update local copy from deploy location Pin
Denis bda22-Feb-07 6:10
memberDenis bda22-Feb-07 6:10 
AnswerRe: Step 5: Fails to update local copy from deploy location Pin
Denis bda28-Feb-07 4:09
memberDenis bda28-Feb-07 4:09 
GeneralIf Server is OFFLINE - custom update functionality Pin
Sanjeev Thazhathaveetil10-Mar-07 4:29
memberSanjeev Thazhathaveetil10-Mar-07 4:29 
Questionstep 5 problem Pin
jdrawmer21-Feb-07 0:41
memberjdrawmer21-Feb-07 0:41 
AnswerRe: step 5 problem Pin
jalekz21-Feb-07 8:53
memberjalekz21-Feb-07 8:53 
AnswerRe: step 5 problem [modified] Pin
Member 213663821-May-08 3:20
memberMember 213663821-May-08 3:20 
Generalrecipients, subject, body of a Mail not recognised Pin
axn3212-Feb-07 22:03
memberaxn3212-Feb-07 22:03 
Hi All

I have added a control to the new mail window. Problem is, is in my code (vb6,outlook XP) i have the following code
My problem is that I doesn't recognise the recipients as well other fields of mail (subject, body). and
MsgBox ("To= " & mTo & " Cc=" & mCc & " Bcc=" & mBcc) shows nothing in TO,CC,BCC etc.
Please have a look at mycode & suggest me what is wrong there
Thanks in Advance

Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
On Error Resume Next
Dim myInsp As Outlook.Inspector
Set myInsp = Inspector
If myInsp.CurrentItem.Class = olMail Then
Set newMail = myolApp.CreateItem(olMailItem)
'MsgBox ("in new mail")
myInsp.CommandBars.Item("Standard").Visible = True
Set btnNewSend = myInsp.CommandBars("Standard").FindControl(Tag:="btnNewSend")
Set btnNewSend = myInsp.CommandBars("Standard").Controls.Add(Type:=msoControlButton, Temporary:=False)
With btnNewSend
.Caption = "New Send"
.Tag = "btnNewSend"
.Style = msoButtonIconAndCaption
.FaceId = 133
End With
newMail = myInsp.currentItem

End If
Private Sub btnNewSend_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
Dim mTo As String
Dim reply As String
Dim msgString As String
Dim mCc As String
Dim mBcc As String
MsgBox (newMail.To)
mTo = Trim(newMail.To)
mCc = Trim(newMail.CC)
mBcc = Trim(newMail.BCC)
MsgBox ("To= " & mTo & " Cc=" & mCc & " Bcc=" & mBcc)
If mTo = "" And mCc = "" And mBcc = "" Then
reply = MsgBox(" you have not specified any recipients for this message." & vbCrLf & " Do you want to continue?", vbYesNo + vbQuestion + vbApplicationModal, "My Addin")
If reply = vbNo Then
CancelDefault = True
Exit Sub
newMail.To = ""
' MsgBox ("To: " & newMail.To & vbCrLf & "cc: " & newMail.CC & vbCrLf & "Bcc: " & newMail.BCC & vbCrLf & "Body: " & newMail.Body)
End If
End If
End Sub

I am using VB 6.0 for Office and VB.NET 2005 for Desktop Application


QuestionUpdate runs from server only Pin
colinmc1-Feb-07 5:18
membercolinmc1-Feb-07 5:18 
AnswerRe: Update runs from server only Pin
Sanjeev Thazhathaveetil1-Feb-07 6:35
memberSanjeev Thazhathaveetil1-Feb-07 6:35 
GeneralRe: Update runs from server only Pin
colinmc6-Feb-07 0:10
membercolinmc6-Feb-07 0:10 
GeneralInstalling on 2K3 with terminal services Pin
bon73329-Jan-07 19:08
memberbon73329-Jan-07 19:08 
GeneralUnable to get plug-in to update from server Pin
Jason Hills20-Dec-06 17:19
memberJason Hills20-Dec-06 17:19 
AnswerRe: Unable to get plug-in to update from server Pin
Jason Hills21-Dec-06 15:17
memberJason Hills21-Dec-06 15:17 
GeneralRe: Unable to get plug-in to update from server [modified] Pin
royal_hale5-Feb-07 12:20
memberroyal_hale5-Feb-07 12:20 
GeneralNow this is more like it. Pin
norm .net1-Dec-06 23:20
membernorm .net1-Dec-06 23:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 1 Dec 2006
Article Copyright 2006 by Sanjeev Thazhathaveetil
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid