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 3 5278
(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
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
"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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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?
...
|
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;...
|
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...
|
by: Srinivas |
last post by:
hi all
how to access the outlook user profiles through VB.net
any help....
thanks in advanc
Srinivas
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |