C # brings up the Outlook interface and sends the specified attachment

Source: Internet
Author: User
Tags mail win32 client
C # on the network to call the Outlook interface to send mail examples of numerous, but all is a simple interface, set the recipient address, message title, body content, etc., but for the delivery of the specified attachment is very little. Also have implementation, but is introduced to the Outlook object library, I do not want to just so a small function to introduce such a big dongdong, too disgusting! Just also want to add this small function to CrossFile2.0, so last night carefully studied the next Outlook call parameters, found or can be implemented in a simple way, now posted to share the following:
Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey (@ "Mailto\shell\open\command") //Here we look for the system's default mail client, other client programs I have not tried, do not know whether this method is feasible

if (Rkey!= null)
{//Find out where the Outlook application is located, or else you can look it up in other ways
String path = Rkey.getvalue (""). ToString () + "";
Path = path. Substring (0, path. IndexOf (""));
Path = path. Replace ("\", "");
Rkey.close ();
Try
{
System.Diagnostics.Process.Start (Path, "-C IPM. note/m Myfriend@hotmail.com&subject=hello "+ this._imagepath);//Call to execute Outlook, focus on the following parameters, the file address of the attachment space separated
}
Catch
{
}
}


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.