473,396 Members | 1,847 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,396 software developers and data experts.

Outlook 2003 Object Model using Visual C# 2005 Express IDE Beta1

Following an intro article from the msdn homepage about using C# to access
the Outlook 2003 Object Model in Applications and Add-Ins, I came across a
problem with the OPine example.

I was reading through the article on the C# msdn home page about introducing
the Outlook 2003 Object Model through C#.

I carefully programmed the OPine example, but after ironing out reference
errors and syntax, etc., I finally had this one annoying error. I can see
obviously what is causing it (two methods with similar names is my guess),
but for the life of me can't figure out how to fix it! The code is EXACTLY as
out of the article...

Error:
Error 1 Ambiguity between
'Microsoft.Office.Interop.Outlook._MailItem.Send() ' and
'Microsoft.Office.Interop.Outlook.ItemEvents_10_Ev ent.Send'
C:\Documents and Settings\rclements\Local Settings\Application
Data\Temporary Projects\OPine\Program.cs 122 19

Here is the code reference:
public static void SendNewMail(ApplicationClass o)
{
// Create a new MailItem.
MailItem myMail =
(MailItem)o.CreateItem(OlItemType.olMailItem);
// Now gather input from user.
Console.Write("Receiver Name: ");
myMail.Recipients.Add(Console.ReadLine());
Console.Write("Subject: ");
myMail.Subject = Console.ReadLine();
Console.Write("Message Body: ");
myMail.Body = Console.ReadLine();
// Send it!
myMail.Send();
}

It is the method Send() in the last line of the static method which causes
the error...

Can anyone help me compile this? How can I force it to choose the correct
option?

Will
Nov 16 '05 #1
3 5283
(myMail as Outlook._MailItem).Send();

Willy.

"WillShakespeare" <Wi*************@discussions.microsoft.com> wrote in
message news:CC**********************************@microsof t.com...
Following an intro article from the msdn homepage about using C# to access
the Outlook 2003 Object Model in Applications and Add-Ins, I came across a
problem with the OPine example.

I was reading through the article on the C# msdn home page about
introducing
the Outlook 2003 Object Model through C#.

I carefully programmed the OPine example, but after ironing out reference
errors and syntax, etc., I finally had this one annoying error. I can see
obviously what is causing it (two methods with similar names is my guess),
but for the life of me can't figure out how to fix it! The code is EXACTLY
as
out of the article...

Error:
Error 1 Ambiguity between
'Microsoft.Office.Interop.Outlook._MailItem.Send() ' and
'Microsoft.Office.Interop.Outlook.ItemEvents_10_Ev ent.Send'
C:\Documents and Settings\rclements\Local Settings\Application
Data\Temporary Projects\OPine\Program.cs 122 19

Here is the code reference:
public static void SendNewMail(ApplicationClass o)
{
// Create a new MailItem.
MailItem myMail =
(MailItem)o.CreateItem(OlItemType.olMailItem);
// Now gather input from user.
Console.Write("Receiver Name: ");
myMail.Recipients.Add(Console.ReadLine());
Console.Write("Subject: ");
myMail.Subject = Console.ReadLine();
Console.Write("Message Body: ");
myMail.Body = Console.ReadLine();
// Send it!
myMail.Send();
}

It is the method Send() in the last line of the static method which causes
the error...

Can anyone help me compile this? How can I force it to choose the correct
option?

Will

Nov 16 '05 #2
Brilliant Willy, thanks!

If you have time, any chance you could explain why this happens? And if I
should look out for similar problems? I ask becaus ethe examples were for
VS.NET 2003, which I have, but was trying out the Beta Express version. Is it
likely a bug, maybe?

I would assume that as the article was written for 2003, then likely this
problem doesn't happen, you see, as I would be surprised if the code was not
tested before publication (well, maybe "surprised" isn't the right word...
maybe irked is better!).

Will

"Willy Denoyette [MVP]" wrote:
(myMail as Outlook._MailItem).Send();

Willy.

"WillShakespeare" <Wi*************@discussions.microsoft.com> wrote in
message news:CC**********************************@microsof t.com...
Following an intro article from the msdn homepage about using C# to access
the Outlook 2003 Object Model in Applications and Add-Ins, I came across a
problem with the OPine example.

I was reading through the article on the C# msdn home page about
introducing
the Outlook 2003 Object Model through C#.

I carefully programmed the OPine example, but after ironing out reference
errors and syntax, etc., I finally had this one annoying error. I can see
obviously what is causing it (two methods with similar names is my guess),
but for the life of me can't figure out how to fix it! The code is EXACTLY
as
out of the article...

Error:
Error 1 Ambiguity between
'Microsoft.Office.Interop.Outlook._MailItem.Send() ' and
'Microsoft.Office.Interop.Outlook.ItemEvents_10_Ev ent.Send'
C:\Documents and Settings\rclements\Local Settings\Application
Data\Temporary Projects\OPine\Program.cs 122 19

Here is the code reference:
public static void SendNewMail(ApplicationClass o)
{
// Create a new MailItem.
MailItem myMail =
(MailItem)o.CreateItem(OlItemType.olMailItem);
// Now gather input from user.
Console.Write("Receiver Name: ");
myMail.Recipients.Add(Console.ReadLine());
Console.Write("Subject: ");
myMail.Subject = Console.ReadLine();
Console.Write("Message Body: ");
myMail.Body = Console.ReadLine();
// Send it!
myMail.Send();
}

It is the method Send() in the last line of the static method which causes
the error...

Can anyone help me compile this? How can I force it to choose the correct
option?

Will


Nov 16 '05 #3

"WillShakespeare" <Wi*************@discussions.microsoft.com> wrote in
message news:94**********************************@microsof t.com...
Brilliant Willy, thanks!

If you have time, any chance you could explain why this happens? And if I
should look out for similar problems? I ask becaus ethe examples were for
VS.NET 2003, which I have, but was trying out the Beta Express version. Is
it
likely a bug, maybe?

I would assume that as the article was written for 2003, then likely this
problem doesn't happen, you see, as I would be surprised if the code was
not
tested before publication (well, maybe "surprised" isn't the right word...
maybe irked is better!).

Will


I don't think it's a bug, apparently the C# compiler team decided to flag an
error when he encounters an object that has an event and a method with the
same name, something they silently resolved in v1.x. You can get around this
issue by an explicit cast to the correct interface (or by using vb.net ;-),
like this:

(myMail as Outlook._MailItem).Send();
or
( (Outlook._MailItem)myMail ).Send();

Willy.
Nov 16 '05 #4

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

Similar topics

7
by: MLH | last post by:
Is the following remotely correct? =DDE("C:\Program Files\Program Files\Outlook Express\OEmig50","Attachment","Name") I'm not sure that OEmig50.exe is the executable for OE. Anybody know? ...
6
by: LEBRUN Thomas | last post by:
Hello :) I would like to use Outlook 2003 in my application so for that, i've added the referece to Outlook 11.0 Object Model to my project. Then, I try this simple code : using System;...
0
by: WillShakespeare | last post by:
Following an intro article from the msdn homepage about using C# to access the Outlook 2003 Object Model in Applications and Add-Ins, I came across a problem with the OPine example. I was...
9
by: Srinivas | last post by:
hi all how to access the outlook user profiles through VB.net any help.... thanks in advanc Srinivas
1
by: Rohan | last post by:
Hi There, I want o access address book of OUTLOOK EXPRESS on Web Clients PC so that he can select addresses from his address book & copy them to our database. Does Outlook Express support an...
9
by: Neil | last post by:
We have an Access 2000 MDB with a SQL 7 back end. We are upgrading SQL Server to SQL 2005, and are considering upgrading to Access 2003. Someone mentioned that they had heard about some...
2
by: Pieter | last post by:
Hi, I'm using a thight integration with Outlook 2003 (with an Exchange server) in my VB.NET (2005) application. Until now I'm using the Outlook Object Model, but it appears to be very slow, and...
0
by: toduro | last post by:
Using Visual C# 2005 Express Edition and Microsoft Office Outlook 2003. An exception with message: "Retrieving the COM class factory for component with CLSID...
3
by: ITrishGuru | last post by:
Hi all, For my IT final year project I have to access mail items in outlook 2003 and parse them. I have read and researched on the net and library for about a week now. I have to do the project...
5
by: fniles | last post by:
I am using VB.NET 2005. I created a project using the Microsoft Outlook 8.0 Object Library (Object Model) in my previous machine. Now that I have a new machine, when I try to compile that program...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.