Peter,
Thank you for your response. However I am not running Webdav and we do not
have Exchange in our enironment.
Below is the code that I have so far. This creates the ics file and places
it as an attachment to an email. However it does not send the email as a
meeting request. It simply sends the email with an attachment. I think I need
to change something in the emails header to make the receiving email client
recognise that it is being sent a meeting request not an email. I am not
quite sure how or what though and that is my question...
Public Function SendAppoinment(ByVal Method As String, ByVal startDate
As String, _
ByVal startTime As String, ByVal endTime As String,
ByVal subject As String, _
ByVal summary As String, ByVal location As String, ByVal
attendeeName As String, _
ByVal attendeeEmail As String, ByVal organizerEmail As
String, _
ByVal organizerName As String, ByVal emailBody As
String, ByVal GUID As String) As Boolean
Const c_strTimeFormat = "yyyyMMddTHHmmssZ"
Dim sStartTime As String = ""
Dim sEndTime As String = ""
Dim sTimeStamp As String = ""
Dim sTempStartTime As String = ""
Dim sTempEndTime As String = ""
Dim sCalendarFile As String = ""
Const VCAL_FILE = "BEGIN:VCALENDAR" & vbCrLf & _
"VERSION:2.0" & vbCrLf & _
"METHOD{0}" & vbCrLf & _
"BEGIN:VEVENT" & vbCrLf & _
"STATUS{1}" & vbCrLf & _
"DTSTART{2}" & vbCrLf & _
"DTEND{3}" & vbCrLf & _
"TRANSP:OPAQUE" & vbCrLf & _
"SEQUENCE:0" & vbCrLf & _
"LOCATION;ENCODING=QUOTED-PRINTABLE:{4}" & vbCrLf
& _
"ORGANIZER;CN=""{5}/OHA"":mailto:{6}" & vbCrLf & _
"UID : {7}" & vbCrLf & _
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{8}" &
vbCrLf & _
"CLASS
UBLIC" & vbCrLf & _
"SUMMARY;ENCODING=QUOTED-PRINTABLE:{9}" & vbCrLf & _
"TRIGGER
T15M" & vbCrLf & _
"PRIORITY:3" & vbCrLf & _
"END:VEVENT" & vbCrLf & _
"END:VCALENDAR"
Dim sMethod As String = ":" & Method
Dim sStatus As String = ":CONFIRMED"
Dim dtStartDate As DateTime = DateTime.Parse(startDate.ToString())
Dim dtStartTime As DateTime = DateTime.Parse(startDate + " " +
startTime.ToString())
Dim dtEndTime As DateTime = DateTime.Parse(startDate + " " +
endTime.ToString())
sTempStartTime = String.Format("{0} {1}",
dtStartDate.ToShortDateString(), dtStartTime.ToLongTimeString())
sTempEndTime = String.Format("{0} {1}",
dtStartDate.ToShortDateString(), dtEndTime.ToLongTimeString())
sTimeStamp =
(DateTime.Parse(sTempStartTime)).ToUniversalTime().ToString(c_strTimeFormat)
sStartTime = String.Format(":{0}", sTimeStamp)
sEndTime = String.Format(":{0}",
(DateTime.Parse(sTempEndTime)).ToUniversalTime().ToString(c_strTimeFormat))
sCalendarFile = String.Format(VCAL_FILE, sMethod, sStatus,
sStartTime, sEndTime, location, organizerName, organizerEmail, GUID, summary,
subject)
' Create the mail message
Dim mail As MailMessage = New MailMessage()
Dim sc As SmtpClient
Dim maTo As MailAddress = New MailAddress(attendeeEmail.Trim(),
attendeeName)
Dim maFrom As MailAddress = New MailAddress(organizerEmail.Trim(),
organizerName)
mail = New MailMessage(maFrom, maTo)
mail.Subject = subject
mail.Body = emailBody
' create the attachment by converting the text to a byte array and
placing it in a
' memory stream object
Dim bAttach() As Byte = Encoding.ASCII.GetBytes(sCalendarFile)
Dim msAttach As New System.IO.MemoryStream(bAttach)
Dim aAttach As Attachment = New Attachment(msAttach, "Event.ics")
mail.Attachments.Add(aAttach)
sc = New SmtpClient(ConfigurationManager.AppSettings("EmailServer"))
sc.Send(mail)
Return True
End Function
Regards,
James