Vs. Net original code of the Program for sending meeting emails

Source: Internet
Author: User

********************* ********************************//

Public struct appointmail
{
Public String from; // the sender's email address.
Public string to; // recipient email address; a string separated by numbers
Public String fromdisplayname; // sender's name
Public String subject; // the title.
Public String body; // body
Public String location; // location
Public datetime stime; // start time
Public datetime etime; // End Time
}

Public static void sendappointmail (appointmail Mail)
{
Mailmessage MSG = new mailmessage ();
Mailaddresscollection attendeelist = new mailaddresscollection ();
String [] sendto = Mail. to. Split (';');
Foreach (string temp in sendto)
{
If (temp. Trim (). length> 3)
{
MSG. bcc. Add (temp );
Attendeelist. Add (temp );
}
}
// Set up the different MIME types contained in the message
System. net. Mime. contenttype texttype = new system. net. Mime. contenttype ("text/plain ");
System. net. Mime. contenttype htmltype = new system. net. Mime. contenttype ("text/html ");
System. net. Mime. contenttype rtftype = new system. net. Mime. contenttype ("text/rtf ");
System. net. Mime. contenttype calendartype = new system. net. Mime. contenttype ("text/calendar ;");
// Add parameters to the calendar Header
Calendartype. Parameters. Add ("method", "request ");
Calendartype. Parameters. Add ("name", "meeting. ICS ");

// Create message body parts

// Create the body in text format

String bodytext = "type: single meeting" R "norganizer: {0}" R "nstart time: {1}" R "nend time: {2}" R "ntime zone: {3} "R" nlocation: {4} "R" N "R" N *~ *~ *~ *~ *~ *~ *~ *~ *~ * "R" N "R" n {5 }";

Bodytext = string. format (bodytext, organizername, start. tolongdatestring () + "" + start. tolongtimestring (), end. tolongdatestring () + "" + end. tolongtimestring (), system. timezone. currenttimezone. standardname, location, summary );

Alternateview textview = alternateview. createalternateviewfromstring (bodytext, texttype );

MSG. alternateviews. Add (textview );

// Create the body in HTML Format

String bodyhtml = "<! Doctype HTML public ""-// W3C // dtd html 3.2 // en ""> "R" n <HTML> "R" n

Bodyhtml = string. format (bodyhtml, summary, organizername, start. tolongdatestring () + "" + start. tolongtimestring (), end. tolongdatestring () + "" + end. tolongtimestring (), system. timezone. currenttimezone. standardname, location, summary );

Alternateview htmlview = alternateview. createalternateviewfromstring (bodyhtml, htmltype );

MSG. alternateviews. Add (htmlview );

// Create the body in vcalendar format
String caldateformat = "yyyymmddthhmmssz ";
String bodycalendar = "begin: vcalendar \ r \ nmethod: Request \ r \ nprodid: Microsoft CDO for Microsoft Exchange \ r \ nversion: 2.0 \ r \ nbegin: vtimezone \ r \ ntzid :( GMT-06.00) Central Time (US & Canada) \ r \ NX-MICROSOFT-CDO-TZID: 11 \ r \ nbegin: Standard \ r \ ndtstart: 160101t020000 \ r \ ntzoffsetfrom: -0500 \ r \ ntzoffsetto:-0600 \ r \ nrrule: freq = yearly; wkst = Mo; interval = 1; bymonth = 11; byday = 1su \ r \ nend: standard \ r \ nbegin: Daylight \ r \ ndtstart: 16010101t020000 \ r \ ntzoffsetfrom:-0600 \ r \ ntzoffsetto:-0500 \ r \ nrrule: freq = yearly; wkst = Mo; interval = 1; bymonth = 3; byday = 2su \ r \ nend: Daylight \ r \ nend: vtimezone \ r \ nbegin: vevent \ r \ ndtstamp: {8} \ r \ ndtstart: {0} \ r \ nsummary: {6} \ r \ nuid: {5} \ r \ nattendee; Role = REQ-PARTICIPANT; partstat = needs-action; RSVP = true; Cn = \ "{9} \": mailto: {9} \ r \ naction; RSVP = true; CN = \ "{4} \": mailto: {4} \ r \ norganizer; Cn = \ "{3} \": mailto: {4} \ r \ nlocation: {2} \ r \ ndtend: {1} \ r \ ndescription: {7} \ n \ r \ nsequence: 1 \ r \ npriority: 5 \ r \ nclass: \ r \ ncreated: {8} \ r \ nlast-modified: {8} \ r \ nstatus: Confirmed \ r \ ntransp: Opaque \ r \ NX-MICROSOFT-CDO-BUSYSTATUS: busy \ r \ NX-MICROSOFT-CDO-INSTTYPE: 0 \ r \ NX-MICROSOFT-CDO-INTENDEDSTATUS: Busy \ r \ NX-MICROSOFT-CDO-ALLDAYEVENT: false \ r \ NX-MICROSOFT-CDO-IMPORTANCE: 1 \ r \ NX-MICROSOFT-CDO-OWNERAPPTID: -1 \ r \ NX-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE: {8} \ r \ NX-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE: {8} \ r \ nbegin: valarm \ r \ naction: Display \ r \ ndescription: reminder \ r \ ntrigger; related = start:-pt00h15m00s \ r \ nend: valarm \ r \ nend: vevent \ r \ nend: vcalendar \ r \ n ";
Bodycalendar = string. Format (bodycalendar,
Mail. stime. touniversaltime (). tostring (caldateformat ),
Mail. etime. touniversaltime (). tostring (caldateformat ),
Mail. Location,
Mail. fromdisplayname,
Mail. From,
Guid. newguid (). tostring ("B "),
Mail. Subject, // Summary
Mail. Body, // body
Datetime. Now. touniversaltime (). tostring (caldateformat ),
Attendeelist. tostring (),
Mail. Body
);
Alternateview calendarview = alternateview. createalternateviewfromstring (bodycalendar, calendartype );
Calendarview. transferencoding = system. net. Mime. transferencoding. sevenbit;
MSG. alternateviews. Add (calendarview );
// Adress the message
MSG. From = new mailaddress (mail. From, mail. fromdisplayname );
MSG. isbodyhtml = true;
Smtpclient smtpclnt = new smtpclient ();
Smtpclnt. Host = configurationmanager. receivettings ["mysmtp"]. tostring ();
Smtpclnt. Send (MSG );
}

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.