C # create an email in outlook to the draft box

Source: Internet
Author: User
Original article: C # create an email in outlook to the draft box

1. Reference Microsoft. Office. InterOP. Outlook. dll

2. Implementation Code

1 public static int sendtodraft (list <string> to, list <string> CC, list <string> BCC, string subject, string content, list <string> attachments, ref string errormessage) 2 {3 int result =-1; 4 try 5 {6 stringbuilder sbattachment = new stringbuilder (); 7 Application objoutlook = new application (); 8 namespace onamespace = objoutlook. getnamespace ("mapi"); 9 mapifolder folder = onamespace. getdefaultfo Lder (oldefaultfolders. olfolderdrafts); 10 mailitem item = (mailitem) (objoutlook. createitem (olitemtype. olmailitem); 11 item. to = getstring (to); 12 item. cc = getstring (CC); 13 item. BCC = getstring (BCC); 14 item. subject = subject; 15 item. htmlbody = content; 16 new log ("Send email outlook "). write ("7"); 17 // Add attachment 18 if (attachments! = NULL & attachments. count> 0) 19 {20 for (INT I = 0; I <attachments. count; I ++) 21 {22 item. attachments. add (@ attachments [I]); 23} 24} 25 item. savesentmessagefolder = folder; 26 item. save (); 27 result = 0; 28} 29 catch (system. exception ex) 30 {31 result =-3; 32 errormessage = ex. message. tostring (); 33} 34 return result; 35}
View code

 

C # create an email in outlook to the draft box

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.