QueryInterface faield for Outlook._Application interface

Add-in Express™ Support Service
That's what is more important than anything else

QueryInterface faield for Outlook._Application interface
HELP!!! 
Christian Barbosa


Guest


I am using Outlook Security Manager, but I have the QueryInterface faield in the second line at this code:

Outlook.Application objOutlook = new Outlook.ApplicationClass();
<<<HERE I GET THE ERROR>>> Outlook.NameSpace objNamespace = objOutlook.GetNamespace("MAPI");
Outlook.MAPIFolder objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Outlook.ContactItem ci = (Outlook.ContactItem)objFolder.Items.Add(Outlook.OlItemType.olContactItem);
ci.FullName = "TESTA OUTLOOK";
ci.Save();

Anybody has any suggestions?

Posted 16 Feb, 2007 15:59:41 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

I have two questions.
1. What version of Outlook do you use?
2. What version of PIAs did you add to your project?



P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 19 Feb, 2007 09:41:50 Top
Christian Barbosa


Guest


Hi,

Thanks for your help!

I am using MS Outlook 2003 and the Interop.Outlook.dll-File Version 9.0.0.0


Posted 22 Feb, 2007 05:54:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Christian, can I test your code on my PC?
Posted 22 Feb, 2007 12:25:31 Top
Christian Barbosa


Guest


Thanks for your help! I am new programming for Outlook and I am lost with some errors.. This code works at many installations but some computers it doesn't work (I think that are computers that have previous outlook versions installed, but I am not sure).

private void button1_Click(object sender, System.EventArgs e)
{
string str_temp = "testeOutlook.log";

System.IO.StreamWriter sw = null;

if(!System.IO.File.Exists(str_temp))
sw = System.IO.File.CreateText(str_temp);
else
{
sw = System.IO.File.AppendText(str_temp);
sw.WriteLine("=============================================");
}

sw.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));

System.Diagnostics.TraceSwitch myTraceSwitch =
new System.Diagnostics.TraceSwitch("SwitchOne", "The first switch");
try
{
myTraceSwitch.Level = System.Diagnostics.TraceLevel.Info;
}
catch(System.Exception ex)
{
str_temp = "ERRO 0: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}

try
{
// This message box displays true, becuase setting the level to
// TraceLevel.Info sets all lower levels to true as well.
str_temp="myTraceSwitch.TraceWarning.ToString(): " + myTraceSwitch.TraceWarning.ToString();
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
}
catch{}

try
{
// This message box displays false.
str_temp="myTraceSwitch.TraceVerbose.ToString(): " + myTraceSwitch.TraceVerbose.ToString();
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
}
catch{}

try
{
objOutlook = new Outlook.ApplicationClass();
}
catch(System.Exception ex)
{
str_temp = "ERRO 1: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}

try
{
cls_security_manager = new AddinExpress.Outlook.SecurityManager();
}
catch(System.Exception ex)
{
str_temp = "ERRO 2: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}

try
{
this.cls_security_manager.ConnectTo(this.objOutlook);
}
catch(System.Exception ex)
{
str_temp = "ERRO 3: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}

try
{
this.cls_security_manager.DisableOOMWarnings = true;
}
catch(System.Exception ex)
{
str_temp = "ERRO 4: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}

if(this.chk_add_contato.Checked)
{
try
{
Outlook.NameSpace objNamespace = this.objOutlook.GetNamespace("MAPI");
Outlook.MAPIFolder objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

Outlook.ContactItem ci = (Outlook.ContactItem)objFolder.Items.Add(Outlook.OlItemType.olContactItem);
ci.FullName = "TESTA OUTLOOK";
ci.Save();

str_temp = "ITEM: " + ci.EntryID + " : " + ci.FullName;

//ci.Delete();

sw.WriteLine(str_temp);
}
catch(System.Exception ex)
{
str_temp = "ERRO 5: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}
}

try
{
this.cls_security_manager.DisableOOMWarnings = false;
}
catch(System.Exception ex)
{
str_temp = "ERRO 6: " + ex.Message;
sw.WriteLine(str_temp);
//MessageBox.Show(str_temp);
//return;
}

str_temp = "!!! FIM DO PROCESSO !!!\r\ncls_security_manager: '" + cls_security_manager + "'\r\nobjOutlook: '" + objOutlook + "'";
sw.WriteLine(str_temp);
sw.Close();
}
Posted 23 Feb, 2007 06:23:20 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Christian, could you please check if the problematic PCs have only one version of Outlook installed?
Posted 23 Feb, 2007 13:52:42 Top
Christian Barbosa


Guest


This computer had Outlook 2000, then the user upgraded to Outlook XP and now he is using Outlook 2003.

I think this is the problem, when the user has done upgrades..
Posted 23 Feb, 2007 13:58:42 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Christian, I would advise you to uninstall MS Office completely and then install Office 2003 again.
Posted 23 Feb, 2007 14:22:05 Top
Christian Barbosa


Guest


:-(

I will try.

Thanks
Posted 23 Feb, 2007 14:26:15 Top