Hi,
I'm trying to code a application that can create a new email in Outlook
I have coded my project in VS 2003, but now I have upgraded to VS 2005.
I can not build my project anymore, I get a looooooong error. I can also
see, when I add a reference to my project, that the Microsoft.Office.Core
and the Outlook References have a yellow exclamation mark.
If I remove my reference to the Outlook object model, the code marked with a
"*" gives a error:
Error 1 The type or namespace name 'Outlook' could not be found (are you
missing a using directive or an assembly reference?)
C:\CSharp\Projects\C5Mailer\C5Mailer\Program.cs 172 16 C5Mailer
My code snippet:
....
*public Outlook.Application oApp;
*public Outlook._NameSpace oNameSpace;
*public Outlook._MailItem oMailItem;
*Outlook.Attachment myAttach;
public Mail(string mailadr1, string mailbody1, string mailsub1,
string mailatt1, string skabelon)
{
oApp = new Microsoft.Office.Interop.Outlook.Application();
oNameSpace = oApp.GetNamespace("MAPI");
oMailItem =
(Microsoft.Office.Interop.Outlook._MailItem)oApp.C reateItem(Outlook.OlItemType.olMailItem);
oMailItem.To = mailadr1;
oMailItem.Subject = mailsub1;
if (skabelon.Equals("nej"))
{
oMailItem.HTMLBody = mailbody1;
}
else
{
StreamReader sr = new StreamReader(skabelon,
Encoding.GetEncoding("iso-8859-1"));
string htmlbody = sr.ReadToEnd();
sr.Close();
oMailItem.HTMLBody = htmlbody;
}
myAttach = oMailItem.Attachments.Add(mailatt1, 1, 1, mailatt1);
....
Please help me on my way again. :)
Best regards
Mads