If you are getting "There was an error during installation. Value does not fall within the expected range." error along with following exception:
************** Exception Text **************System.ArgumentException: Value does not fall within the expected range.at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
and getting prompt as displayed below:
Please make sure that, We are not using special character like "&" in the manufacturer property of the VSTO 3.0 Add-in MSI setup project.
In the above scenario we have Manufacturer Property value as “ABC & XYZ Inc” and we are getting exception as mentioned above when we start Outlook 2007 after installing add-in.
We can easily see from the snapshot that VSTO runtime is escaping "&" from the file path.
However, if we remove “&” from the Manufacturer Property value as “ABC XYZ Inc” add-in get installed and loaded as expected.
So, We should not use special character in the Manufacturer Property for VSTO 3.0 Add-ins MSI setup to workaround this bug.
If the SMTP event sink on Exchange Server 2003 is not firing and not working as expected.
Please make sure that Event sink .vbs file is saved in ANSI Encoding not in UNICODE.
Because Event sink file in UNICODE will break script parser and hence Event Sink would not work.
How to save Event Sink file in ANSI Encoding?
· Open the Event Sink file using Notepad.
· File -> Save As
· Select -> Encoding as “ANSI”
· Save -> Click Yes for “File already exists, Do you want to replace it” prompt.
For sample SMTP event sink we can refer to the below mentioned article:
How to add a disclaimer to outgoing SMTP messages in Visual Basic script
http://support.microsoft.com/kb/317680
HTML controls are not appearing properly in the email on Outlook 2007. This behavior of Outlook2007 is by design. Here are link related to the issue.
· Outlook 2007 uses only Word as the e-mail editorhttp://support.microsoft.com/?id=933793
· Microsoft Office Outlook 2007 e-mail editor white paperhttp://office.microsoft.com/en-us/outlook/HA102109301033.aspx
· 2007 Office System Tool: Outlook HTML and CSS Validatorhttp://www.microsoft.com/downloads/details.aspx?familyid=0b764c08-0f86-431e-8bd5-ef0e9ce26a3a&displaylang=en
· Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 1 of 2)http://msdn2.microsoft.com/en-us/library/aa338201.aspx
· Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 2 of 2)http://msdn2.microsoft.com/en-us/library/aa338200.aspx
We can refer to "Unsupported HTML Attributes Compared with the HTML 4.01 Specification" of the “Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 1 of 2)” article, it clearly states that what all is supported/unsupported.
One can use either of the following workarounds:
Steps to view HTML controls in mail item on Outlook 2007
· Open the Outlook Mail Item (Double click on the mail item).
· Click on “Other Action” on Message Ribbon.
· Select “View in Browser”.
· A new browser window will open with mail body having all HTML controls.
Or
Set AutoPreview (on by default) on Outlook2007. If you add your HTML as an attachment to the message, a user could click on the attachment. It would then be “previewed” in the message and the controls are displayed correctly.
Use the following code snippets to wire an event in C# to capture the click event of the command button on the Outlook Custom Form.
1: /*NOTE: Following programming examples is for illustration only, without warranty either expressed or implied,
2: including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose.
3: This sample code assumes that you are familiar with the programming language being demonstrated and the tools used
4: to create and debug procedures.*/
5:
6: namespace MyOLAddin
7: {
8: using System.Windows.Forms;
9: using System;
10: using Microsoft.Office.Core;
11: using Extensibility;
12: using System.Runtime.InteropServices;
13: using Outlook= Microsoft.Office.Interop.Outlook ;
14: using Microsoft.Vbe.Interop.Forms;
15:
16: /// <summary>
17: /// The object for implementing an Add-in.
18: /// </summary>
19: /// <seealso class='IDTExtensibility2' />
20: [GuidAttribute("406F2E78-C45C-4C12-AEB6-244837293650"), ProgId("MyOLAddin.Connect")]
21: public class Connect : Object, Extensibility.IDTExtensibility2
22: {
23: /// <summary>
24: /// Implements the constructor for the Add-in object.
25: /// Place your initialization code within this method.
26: /// </summary>
27: ///
28:
29: Outlook.Application m_outlook;
30: Outlook.Inspectors m_inspectors;
31: public Connect()
32: {
33:
34: }
35:
36: /// <summary>
37: /// Implements the OnConnection method of the IDTExtensibility2 interface.
38: /// Receives notification that the Add-in is being loaded.
39: /// </summary>
40: /// <param term='application'>
41: /// Root object of the host application.
42: /// </param>
43: /// <param term='connectMode'>
44: /// Describes how the Add-in is being loaded.
45: /// </param>
46: /// <param term='addInInst'>
47: /// Object representing this Add-in.
48: /// </param>
49: /// <seealso class='IDTExtensibility2' />
50: public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
51: {
52: m_outlook = application as Outlook.Application;
53: m_inspectors = m_outlook.Inspectors;
54: m_inspectors.NewInspector +=new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(myInspColl_NewInspector);
55: }
56:
57: /// <summary>
58: /// Implements the OnDisconnection method of the IDTExtensibility2 interface.
59: /// Receives notification that the Add-in is being unloaded.
60: /// </summary>
61: /// <param term='disconnectMode'>
62: /// Describes how the Add-in is being unloaded.
63: /// </param>
64: /// <param term='custom'>
65: /// Array of parameters that are host application specific.
66: /// </param>
67: /// <seealso class='IDTExtensibility2' />
68: public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
69: {
70: }
71:
72: /// <summary>
73: /// Implements the OnAddInsUpdate method of the IDTExtensibility2 interface.
74: /// Receives notification that the collection of Add-ins has changed.
75: /// </summary>
76: /// <param term='custom'>
77: /// Array of parameters that are host application specific.
78: /// </param>
79: /// <seealso class='IDTExtensibility2' />
80: public void OnAddInsUpdate(ref System.Array custom)
81: {
82: }
83:
84: /// <summary>
85: /// Implements the OnStartupComplete method of the IDTExtensibility2 interface.
86: /// Receives notification that the host application has completed loading.
87: /// </summary>
88: /// <param term='custom'>
89: /// Array of parameters that are host application specific.
90: /// </param>
91: /// <seealso class='IDTExtensibility2' />
92: public void OnStartupComplete(ref System.Array custom)
93: {
94: }
95:
96: /// <summary>
97: /// Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
98: /// Receives notification that the host application is being unloaded.
99: /// </summary>
100: /// <param term='custom'>
101: /// Array of parameters that are host application specific.
102: /// </param>
103: /// <seealso class='IDTExtensibility2' />
104: public void OnBeginShutdown(ref System.Array custom)
105: {
106:
107: }
108:
109: private void myInspColl_NewInspector(Outlook.Inspector inspector)
110: {
111: Microsoft.Vbe.Interop.Forms.ControlClass mc;
112: Microsoft.Vbe.Interop.Forms.CommandButton cb;
113: // Here we wire up the click event of the CommandButton1 on the "P.2" of the Outlook Custom Form
114: try
115: {
116: Microsoft.Vbe.Interop.Forms.UserForm userform;
117:
118: object obTemp = ((Outlook.Pages) (Inspector.ModifiedFormPages))["P.2"];
119:
120: userform = (Microsoft.Vbe.Interop.Forms.UserForm) obTemp;
121:
122: mc = (ControlClass) userform.Controls._GetItemByName("CommandButton1");
123:
124: cb = (CommandButton) mc;
125:
126: cb.Click+=new CommandButtonEvents_ClickEventHandler(cb_Click);
127:
128: }
129: catch (Exception)
130: {
131: //MessageBox.Show(e.ToString());
132: mc = null;
133: }
134: }
135:
136: //This is event handler of the CommandButton1 Click's event
137: private void cb_Click()
138: {
139: MessageBox.Show("cb");
140: }
141: }
142: }
We can refer to the following KB as in case of some issue related to using Microsoft.Vbe.Introp.Forms :BUG: "Attempt to Access the Method Failed" Error Message When You Use a Reference to the Wrong Microsoft Forms 2.0 Object Libraryhttp://support.microsoft.com/kb/824009
1: 'Sending SMTP Mail by Port 25 Using CDOSYS with Basic Authentication
2: 'Refer the following article for sending mail with out using authentication : http://msdn.microsoft.com/en-us/library/ms992546(EXCHG.65).aspx
3: 'IMP: Please update the TODO: marked line as per the information required earlier than using the script
4:
5: Dim iMsg
6: Dim iConf
7: Dim Flds
8: Dim strHTML
9: Dim strSmartHost
10:
11: Const cdoSendUsingPort = 2
12: Const cdoBasic = 1
13:
14: strSMTPServer = "mail.example.com" 'TODO:
15: username = "user" 'TODO:
16: password = "password" 'TODO:
17:
18:
19: set iMsg = CreateObject("CDO.Message")
20: set iConf = CreateObject("CDO.Configuration")
21:
22: Set Flds = iConf.Fields
23:
24: ' set the CDOSYS configuration fields to use port 25 on the SMTP server
25:
26: With Flds
27: .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
28: .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
29: .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
30: .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
31: .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = username
32: .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password
33: .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
34: .Update
35: End With
36:
37: ' build HTML for message body
38: strHTML = "<HTML>"
39: strHTML = strHTML & "<HEAD>"
40: strHTML = strHTML & "<BODY>"
41: strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
42: strHTML = strHTML & "</BODY>"
43: strHTML = strHTML & "</HTML>"
44:
45: ' apply the settings to the message
46: With iMsg
47: Set .Configuration = iConf
48: .To = "nrnoble@example.com" 'TODO:
49: .From = "nrnoble@example.com" 'TODO:
50: .Subject = "This is a test CDOSYS message (Sent via Port 25) with Basic Authentication"
51: .HTMLBody = strHTML
52: .Send
53: End With
54:
55: ' cleanup of variables
56: Set iMsg = Nothing
57: Set iConf = Nothing
58: Set Flds = Nothing
59:
60:
We can enable error logging and displaying of error message for the VSTO add-in by setting environment variables VSTO_SUPPRESSDISPLAYALERTS and VSTO_LOGALERTS.
To display each error in a message box, set the VSTO_SUPPRESSDISPLAYALERTS variable to 0 (zero). You can suppress the messages by setting the variable to 1 (one). To write the errors to a log file, set the VSTO_LOGALERTS variable to 1 (one). Visual Studio Tools for Office creates the log file in the folder that contains the application manifest. The default name is <Manifestname>.manifest.log.
We can refer to the article mentioned below:
Visual Studio Tools for the Microsoft Office System : Debugging in Application-Level Projects http://msdn.microsoft.com/en-us/library/ms269003(VS.80).aspx
Starting in Visual Studio 2008 Service Pack 1 (SP1), you can use the event viewer in Windows to see error messages that are captured by the Visual Studio Tools for Office runtime when you install or uninstall Visual Studio Tools for Office solutions. You can use these messages from the event logger to resolve installation and deployment problems.
You can enable the event logger by setting the VSTO_EVENTLOGDISABLED environment variable to "0".
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0): Event Logging (2007 System)http://msdn.microsoft.com/en-us/library/cc442816.aspx
We can also use AddinSpy to gather information for troubleshooting
Using AddinSpy and AS Diagnostic Tools for Microsoft Office Add-inshttp://msdn.microsoft.com/en-us/library/cc984533.aspx
We can also use VSTO Troubleshooter which is part of VSTO Power Tools. It is a diagnostic tool that examines a computer looking for the necessary prerequisites for running Visual Studio Tools for Office solutions.
Microsoft Visual Studio Tools for the Office System Power Tools v1.0.0.0http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&displaylang=en
We can also have look at some troubleshooting techniques posted by my colleagues:
Dave @ http://blogs.msdn.com/dvespa/archive/2008/09/30/troubleshooting-outlook-com-addins-introduction.aspx
Praveen @ http://blogs.msdn.com/vsod/archive/2008/04/22/Troubleshooting-com-add-in-load-failures.aspx