473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Outlook new mail code - getting exclamation marks when adding Microsoft Outlook Object Library

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
Sep 15 '06 #1
0 1978

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fritz Switzer | last post by:
Can anyone provide a small snippet in C# that pulls out the Contacts in Outlook XP. I've seen a couple of examples in C++ and VB in previous newsgroup posts, but either the originals didn't work...
4
by: Max | last post by:
Hi, I would like to have a button and a combo box with options to select various versions of Microsoft Outlook: 2002, 2003. The user selects the email client and clicks the button. The only...
4
by: John | last post by:
Hi Does anyone have a vb.net example of how to use redemption to send mail through outlook? Many Thanks Regards
5
by: TM | last post by:
I would like to write a little app in Visual Basic .net as an add-in to Outlook 2003 so that I can quickly get a list of contact names and email addresses, then when I click on a name or email...
10
by: John | last post by:
Hi When I open a new outlook email from vb.net, sometimes outlook is very slow to appear or occasionally outlook freezes completely. I am targeting mixed office2000/xp environments so I am...
2
by: Roger | last post by:
I am creating an application that will sit on a client pc and monitor the inbox. When an e-mail enters the inbox, then an even will be fired and I will then be able to process the mail. I have...
8
by: Li Pang | last post by:
Hi, I used following codes to pass a message item from CDO to Outlook. They worked fine when I used outlook 2000, but get an error of "Specified cast is not valid." when I used Outlook 2003....
26
by: Tom Becker | last post by:
Is there a way, from Access, to programmatically click the Send and Receive button in Outlook?
1
by: Marc | last post by:
Hello, Am getting acquainted with VSTO and Visual Studio. I have been really successful adding references to the PIAs for Word, Outlook, Excel, etc. to Console applications and VB applications....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.