Use C # to simulate Outlook sending messages, code compilation error

Source: Internet
Author: User

Add Outlook API

1 using OutLook = Microsoft.Office.Interop.Outlook;

Send Message method

1  Public voidSendEmail ()2 {3Outlook.Application app =Newoutlook.application ();4Outlook.NameSpace ns = App. GetNamespace ("MAPI");5Ns. Logon ("Servername\\username","Password",false,true);6     Outlook.MailItem message = (Outlook.MailItem) app. CreateItem (OutLook.OlItemType.olMailItem); 7Message. Subject ="subject";8Message. to =the account@XXX. com";9Message. Body ="Hello world!";TenMessage. Display (true); One message. Send (); A NS. Logoff (); -}

The compilation error is as follows:

Method "Microsoft.office.interop.outlook._mailitem.send ()" and non-method "Microsoft.Office.Interop.Outlook.ItemEvents_10_ Event.send "There is ambiguity between the two. The method group will be used.

Modify the 6th line in the preceding code snippet to read as follows:

1 OutLook. _mailitem message = (Outlook.MailItem) app. CreateItem (OutLook.OlItemType.olMailItem);

Problem Solving!

Use C # to simulate Outlook sending messages, code compilation error

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.