À
सिदà¥à¤§à¤¾à¤°à¥à¤¥
Hi All,
i have created a meeting request.It is working
Now the problem is that i want to send a document as an attachment.
How to do that?
I have a doument in my local drive.
here is my code
==========
public void CreateMeetingRequest(string startDate, string endDate,
string organizerEmail, string attendeeList)
{
string summary = "Please Ignore";
string location = "GG";
string organizerName = "Siddharth";
try
{
dtmStartTime = DateTime.Parse(startDate);
dtmEndTime = DateTime.Parse(endDate);
MailMessage msg = new MailMessage(); // Set up the
different mime types contained in the message
msg.IsBodyHtml = true;
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 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,
dtmStartTime.ToLongDateString() + " " + dtmStartTime.ToLongTimeString
(), dtmEndTime.ToLongDateString() + " " + dtmEndTime.ToLongTimeString
(), System.TimeZone.CurrentTimeZone.StandardName, location, "Hello
World");
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<HEAD>\r\n<META HTTP-EQUIV=\"Content-Type
\" CONTENT=\"text/html; charset=utf-8\">\r\n<META NAME=\"Generator\"
CONTENT=\"MS Exchange Server version 6.5.7652.24\">\r\n<TITLE>{0}</
TITLE>\r\n</HEAD>\r\n<BODY>\r\n<!-- Converted from text/plain format --
> \r\n<P><FONT SIZE=2>Type:Single Meeting<BR>\r\nOrganizer:{1}<BR>\r
\nStart Time:{2}<BR>\r\nEnd Time:{3}<BR>\r\nTime Zone:{4}<BR>\r
\nLocation:{5}<BR>\r\n<BR>\r\n*~*~*~*~*~*~*~*~*~*<BR>\r\n<BR>\r\n{6}
<BR>\r\n</FONT>\r\n</P>\r\n\r\n</BODY>\r\n</HTML>";
bodyHTML = string.Format(bodyHTML, "Hello World",
organizerName, dtmStartTime.ToLongDateString() + " " +
dtmStartTime.ToLongTimeString(), dtmEndTime.ToLongDateString() + " " +
dtmEndTime.ToLongTimeString(),
System.TimeZone.CurrentTimeZone.StandardName, location, summary);
AlternateView HTMLView =
AlternateView.CreateAlternateViewFromString(bodyHTML, HTMLType);
msg.AlternateViews.Add(HTMLView); //create the Body
in VCALENDAR format
ArrayList arrSuperAdmin = new ArrayList();
arrSuperAdmin.AddRange(attendeeList.Split
(Convert.ToChar(";")));
StringBuilder sbAttendee = new StringBuilder();
StringBuilder sbUrl = new StringBuilder();
//attendeeList
for (int i = 0; i < arrSuperAdmin.Count; i++)
{
sbAttendee.Append("ATTENDEE;ROLE=REQ-
PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=" + arrSuperAdmin
.ToString() + ":MAILTO:\"" + arrSuperAdmin.ToString() + " \r
\n");
}
string calDateFormat = "yyyyMMddTHHmmssZ";
sbUrl.Append("ATTACH;VALUE=URL:http://10.10.201.77/RM/
Resumes/a.doc \r\n");
string bodyCalendar = "BEGIN:VCALENDAR\r
\nMETHOD:REQUEST\r\nPRODID:Microsoft CDO for Microsoft Exchange\r
\nVERSION:2.0\r\nBEGIN:VTIMEZONE\r\nTZIDGMT-06.00) Central Time (US
& Canada)\r\nX-MICROSOFT-CDO-TZID:11\r\nBEGIN:STANDARD\r\nDTSTART:
16010101T020000\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r
\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\r
\nEND:STANDARD\r\nBEGINAYLIGHT\r\nDTSTART:16010101T020000\r
\nTZOFFSETFROM:-0600\r\nTZOFFSETTO:-0500\r
\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\r
\nENDAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTAMP:{8}\r
\nDTSTART:{0}\r\nSUMMARY:{7}\r\nUID:{5}\r\n" + sbAttendee.ToString() +
" ACTION;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\nACTIONISPLAY\r
\nDESCRIPTION:REMINDER\r\nTRIGGER;RELATED=STARTT00H15M00S\r
\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
bodyCalendar = string.Format
(bodyCalendar,dtmStartTime.ToUniversalTime().ToString(calDateFormat),
dtmEndTime.ToUniversalTime().ToString(calDateFormat), location,
organizerName, organizerEmail, Guid.NewGuid().ToString("B"), summary,
"Test", DateTime.Now.ToUniversalTime().ToString
(calDateFormat),attendeeList);
AlternateView calendarView =
AlternateView.CreateAlternateViewFromString(bodyCalendar,
calendarType);
calendarView.TransferEncoding =
TransferEncoding.SevenBit;
msg.AlternateViews.Add(calendarView); // Adress
the message
msg.From = new MailAddress
(organizerEmail);
for (int i = 0; i < arrSuperAdmin.Count; i++)
{
msg.To.Add(arrSuperAdmin.ToString());
}
msg.Subject = "Test";
SmtpClient loSMTP = new SmtpClient("10.201.10.55",
26);
loSMTP.Send(msg);
}
catch (Exception ex)
{
throw ex;
}
}
=================
Please help me
i have created a meeting request.It is working
Now the problem is that i want to send a document as an attachment.
How to do that?
I have a doument in my local drive.
here is my code
==========
public void CreateMeetingRequest(string startDate, string endDate,
string organizerEmail, string attendeeList)
{
string summary = "Please Ignore";
string location = "GG";
string organizerName = "Siddharth";
try
{
dtmStartTime = DateTime.Parse(startDate);
dtmEndTime = DateTime.Parse(endDate);
MailMessage msg = new MailMessage(); // Set up the
different mime types contained in the message
msg.IsBodyHtml = true;
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 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,
dtmStartTime.ToLongDateString() + " " + dtmStartTime.ToLongTimeString
(), dtmEndTime.ToLongDateString() + " " + dtmEndTime.ToLongTimeString
(), System.TimeZone.CurrentTimeZone.StandardName, location, "Hello
World");
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<HEAD>\r\n<META HTTP-EQUIV=\"Content-Type
\" CONTENT=\"text/html; charset=utf-8\">\r\n<META NAME=\"Generator\"
CONTENT=\"MS Exchange Server version 6.5.7652.24\">\r\n<TITLE>{0}</
TITLE>\r\n</HEAD>\r\n<BODY>\r\n<!-- Converted from text/plain format --
> \r\n<P><FONT SIZE=2>Type:Single Meeting<BR>\r\nOrganizer:{1}<BR>\r
\nStart Time:{2}<BR>\r\nEnd Time:{3}<BR>\r\nTime Zone:{4}<BR>\r
\nLocation:{5}<BR>\r\n<BR>\r\n*~*~*~*~*~*~*~*~*~*<BR>\r\n<BR>\r\n{6}
<BR>\r\n</FONT>\r\n</P>\r\n\r\n</BODY>\r\n</HTML>";
bodyHTML = string.Format(bodyHTML, "Hello World",
organizerName, dtmStartTime.ToLongDateString() + " " +
dtmStartTime.ToLongTimeString(), dtmEndTime.ToLongDateString() + " " +
dtmEndTime.ToLongTimeString(),
System.TimeZone.CurrentTimeZone.StandardName, location, summary);
AlternateView HTMLView =
AlternateView.CreateAlternateViewFromString(bodyHTML, HTMLType);
msg.AlternateViews.Add(HTMLView); //create the Body
in VCALENDAR format
ArrayList arrSuperAdmin = new ArrayList();
arrSuperAdmin.AddRange(attendeeList.Split
(Convert.ToChar(";")));
StringBuilder sbAttendee = new StringBuilder();
StringBuilder sbUrl = new StringBuilder();
//attendeeList
for (int i = 0; i < arrSuperAdmin.Count; i++)
{
sbAttendee.Append("ATTENDEE;ROLE=REQ-
PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=" + arrSuperAdmin
.ToString() + ":MAILTO:\"" + arrSuperAdmin.ToString() + " \r
\n");
}
string calDateFormat = "yyyyMMddTHHmmssZ";
sbUrl.Append("ATTACH;VALUE=URL:http://10.10.201.77/RM/
Resumes/a.doc \r\n");
string bodyCalendar = "BEGIN:VCALENDAR\r
\nMETHOD:REQUEST\r\nPRODID:Microsoft CDO for Microsoft Exchange\r
\nVERSION:2.0\r\nBEGIN:VTIMEZONE\r\nTZIDGMT-06.00) Central Time (US
& Canada)\r\nX-MICROSOFT-CDO-TZID:11\r\nBEGIN:STANDARD\r\nDTSTART:
16010101T020000\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r
\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\r
\nEND:STANDARD\r\nBEGINAYLIGHT\r\nDTSTART:16010101T020000\r
\nTZOFFSETFROM:-0600\r\nTZOFFSETTO:-0500\r
\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\r
\nENDAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nDTSTAMP:{8}\r
\nDTSTART:{0}\r\nSUMMARY:{7}\r\nUID:{5}\r\n" + sbAttendee.ToString() +
" ACTION;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\nACTIONISPLAY\r
\nDESCRIPTION:REMINDER\r\nTRIGGER;RELATED=STARTT00H15M00S\r
\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n";
bodyCalendar = string.Format
(bodyCalendar,dtmStartTime.ToUniversalTime().ToString(calDateFormat),
dtmEndTime.ToUniversalTime().ToString(calDateFormat), location,
organizerName, organizerEmail, Guid.NewGuid().ToString("B"), summary,
"Test", DateTime.Now.ToUniversalTime().ToString
(calDateFormat),attendeeList);
AlternateView calendarView =
AlternateView.CreateAlternateViewFromString(bodyCalendar,
calendarType);
calendarView.TransferEncoding =
TransferEncoding.SevenBit;
msg.AlternateViews.Add(calendarView); // Adress
the message
msg.From = new MailAddress
(organizerEmail);
for (int i = 0; i < arrSuperAdmin.Count; i++)
{
msg.To.Add(arrSuperAdmin.ToString());
}
msg.Subject = "Test";
SmtpClient loSMTP = new SmtpClient("10.201.10.55",
26);
loSMTP.Send(msg);
}
catch (Exception ex)
{
throw ex;
}
}
=================
Please help me