A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

programmatically add attachments to meeting requests



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 20th 08, 05:59 PM posted to microsoft.public.outlook.program_addins
Steve*n
external usenet poster
 
Posts: 4
Default programmatically add attachments to meeting requests

I have some code, referenced below which creates a MailMessage which is
really a meeting request because when it shows up in my Outlook I can
accept/decline like with any other meeting request. This is great. However,
now I am trying to add attachments to the MailMessage using the code
commented below, when I do this, it successfully adds the attachment however
when the email is received in Outlook it is no longer a meeting request I
can accept/decline, instead it's just an email with the meeting information
inside of it and the attachment attached. How do I programmatically attach
the attachment while at the same time keeping the meeting request
functionality? Or if this is the incorrect newsgroup, please point me to the
correct one?
Thanks

public static MailMessage CreateMeetingRequest(DateTime start, DateTime end,
string subject, string summary, string location, string organizerName,
string organizerEmail, MailAddressCollection attendeeList, Attachment
attachedFile, string fileName)
{
MailMessage msg = new MailMessage();

//add the attachment to the appointment, when added it shows up
as a regular email and not the expected appointment like I thought it would
if (attachedFile != null)
{
msg.Attachments.Add(attachedFile);
}

// 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 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 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(bodyTe xt, textType);
LinkedResource lr = new LinkedResource(fileName);
textView.LinkedResources.Add(lr);
msg.AlternateViews.Add(textView);

//create the Body in HTML format
string bodyHTML = "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML
3.2//EN\"\r\nHTML\r\nHEAD\r\nMETA HTTP-EQUIV=\"Content-Type\"
CONTENT=\"text/html; charset=utf-8\"\r\nMETA NAME=\"Generator\"
CONTENT=\"MS Exchange Server version
6.5.7652.24\"\r\nTITLE{0}/TITLE\r\n/HEAD\r\nBODY\r\n!-- Converted
from text/plain format --\r\nPFONT SIZE=2Type:Single
MeetingBR\r\nOrganizer:{1}BR\r\nStart Time:{2}BR\r\nEnd
Time:{3}BR\r\nTime
Zone:{4}BR\r\nLocation:{5}BR\r\nBR\r\n*~*~*~ *~*~*~*~*~*~*BR\r\nBR\r\n{6}BR\r\n/FONT\r\n/P\r\n\r\n/BODY\r\n/HTML";
bodyHTML = string.Format(bodyHTML, summary, organizerName,
start.ToLongDateString() + " " + start.ToLongTimeString(),
end.ToLongDateString() + " " + end.ToLongTimeString(),
System.TimeZone.CurrentTimeZone.StandardName, location, summary);
AlternateView HTMLView =
AlternateView.CreateAlternateViewFromString(bodyHT ML, HTMLType);
HTMLView.LinkedResources.Add(lr);
msg.AlternateViews.Add(HTMLView);

//create the Body in VCALENDAR format
string calDateFormat = "yyyyMMddTHHmmssZ";
string bodyCalendar =
"BEGIN:VCALENDAR\r\nMETHOD:REQUEST\r\nPRODID:Micro soft 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:16010101T0200 00\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r\nRRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMON TH=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;BYMON TH=3;BYDAY=2SU\r\nENDAYLIGHT\r\nEND:VTIMEZONE\r\ nBEGIN:VEVENT\r\nDTSTAMP:{8}\r\nDTSTART:{0}\r\nSUM MARY:{7}\r\nUID:{5}\r\nATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"{9}\":MAILTO:{9}\r\nACTION;R SVP=TRUE;CN=\"{4}\":MAILTO:{4}\r\nORGANIZER;CN=\"{ 3}\":mailto:{4}\r\nLOCATION:{2}\r\nDTEND:{1}\r\nDE SCRIPTION:{7}\\N\r\nSEQUENCE:1\r\nPRIORITY:5\r\nCL ASS:\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\nDE SCRIPTION:REMINDER\r\nTRIGGER;RELATED=START:-PT00H15M00S\r\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCA LENDAR\r\n";
bodyCalendar = string.Format(bodyCalendar,
start.ToUniversalTime().ToString(calDateFormat),
end.ToUniversalTime().ToString(calDateFormat), location, organizerName,
organizerEmail, Guid.NewGuid().ToString("B"), summary, subject,
DateTime.Now.ToUniversalTime().ToString(calDateFor mat), attendeeList);
AlternateView calendarView =
AlternateView.CreateAlternateViewFromString(bodyCa lendar, calendarType);
calendarView.TransferEncoding =
System.Net.Mime.TransferEncoding.SevenBit;
calendarView.LinkedResources.Add(lr);
msg.AlternateViews.Add(calendarView);

// Adress the message
msg.From = new MailAddress(organizerEmail);
foreach (MailAddress attendee in attendeeList)
{
msg.To.Add(attendee);
}

msg.Subject = subject;
return msg;
}


Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically add reminder (if missing) to meeting requests JP[_2_] Outlook and VBA 8 November 5th 07 06:30 PM
Meeting requests received as plain text with attachments Coops Outlook - Calandaring 5 June 15th 07 07:03 PM
create a rule to auto delete attachments on a meeting requests? V-@pearson Outlook - Calandaring 1 June 22nd 06 08:59 PM
How to programmatically save all email attachments in a folder Brian Beck Outlook and VBA 1 April 20th 06 02:47 PM
Deleting Attachments in Meeting Requests [email protected] Outlook - General Queries 0 March 30th 06 06:30 PM


All times are GMT +1. The time now is 09:32 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.