How to send a document Attachment with the Meeting Request.

  • Thread starter Thread starter सिद्धार्थ
  • Start date Start date
Status
Not open for further replies.
À

सिद्धार्थ

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\nTZID:(GMT-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\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:{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\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,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
 
Use the Outlook object model to create the meeting request, don't hack it

from scratch that way. When you have a meeting request item, get its

Attachments collection and add whatever file you want to that collection

using the Add() method.

"?????????" <siddharth.1435@gmail.com> wrote in message

news:3d05998a-26e2-4310-a04e-ad2614a1cc45@y33g2000prg.googlegroups.com...
> 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\nTZID:(GMT-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\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:{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\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,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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Z Send mail and contents of body from ms word document Using Outlook 1
D Using VBA to send Word document as body of message works in 2007, but not in 2003 Outlook VBA and Custom Forms 9
P Removing Outlook 365 Account from Send/Receive Using Outlook 3
J Outlook macro to run before email is being send Outlook VBA and Custom Forms 0
J Saving Send emails to a folder on the server Outlook VBA and Custom Forms 63
J Outlook 2019 Pick the Folder Location to save send emails Outlook VBA and Custom Forms 0
D Send email from Outlook Alias using Mac? Using Outlook 0
E FUNCTION SEND/RECEIVE OUTLLOK AND VB6 Outlook VBA and Custom Forms 3
R How to use VB .Net to send emails? Outlook VBA and Custom Forms 0
J Outlook VBA to send from Non-default Account & Data Files Outlook VBA and Custom Forms 4
C Synchronization and taking forever to send Using Outlook 2
D Send on behalf of does not store the base mailbox Using Outlook 0
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
TomHuckstep Remove Send/Receive All Folders (IMAP/POP) button from Outlook 365 Ribbon Using Outlook 2
J Macro to send email as alias Outlook VBA and Custom Forms 0
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
T Outlook 2010 recipient no longer shows in 'Send To' Using Outlook 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
L How to avoid issues with "Send on Behalf" Using Outlook 3
M Outlook 365 refuses to send email Using Outlook 0
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
M I cant send emails via Outlook in my W10 PC. Using Outlook 3
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
G Send a greeting message to a contact on birthday Outlook VBA and Custom Forms 5
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
R How to restrict GWSMO sync to Outlook Send/Receive cycles Using Outlook 0
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to send from acct 2 but showing email name from acct 1 as From - alias? Using Outlook 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
C Synchronizing subscribed folders causes hanging during send/receive process Using Outlook 2
M Extract all links from Outlook email, send to Excel Using Outlook 2
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
T After I send a new email, it remains in the Draft folder Using Outlook.com accounts in Outlook 3
B Programmatically force html send and insert clipboard contents into body Outlook VBA and Custom Forms 0
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
M ERROR: None of your email accounts could send to this recipient Using Outlook 2
C Send/receive error 80040119 Using Outlook 2
J Send Again NDR Outlook VBA and Custom Forms 1
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
ChrisK2 Send email to advertise@slipstick.com fails: "The group advertising isn't set up to receive messages from..." Using Outlook 3
B resend if no reply and send an automatic reminder Outlook VBA and Custom Forms 0
F Send As a Gmail account via outlook Web Using Outlook 3
R auto send email when meeting closes from a shared calendar only Outlook VBA and Custom Forms 2

Similar threads

Back
Top