Sending Outlook/Lotus Meeting invites programatically

Joined
Jul 5, 2006
Messages
9
Programming Experience
1-3
Hi Guys,

I am currently trying to develop a routine which monitors a database and sends Outlook/Lotus Notes Invites when certain criteria are met. Currently I am sending e-mails using System.Web.Mail.

I currently create the message object using the following code:

Dim smtpMail As System.Web.Mail.SmtpMail
Dim MailMessage As New System.Web.Mail.MailMessage
Dim NumSent As Integer
Dim ICS_ID
Dim strICS As String

ICS_ID = Year(Now) & Month(Now) & Now.Day & Now.Hour & Now.Minute & Now.Second
'Create the VCARD
strICS = "BEGIN:VCALENDAR" & vbCrLf
strICS = strICS & "PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN" & vbCrLf
strICS = strICS & "VERSION:2.0" & vbCrLf
strICS = strICS & "METHOD:REQUEST" & vbCrLf
strICS = strICS & "BEGIN:VEVENT" & vbCrLf
strICS = strICS & "ATTENDEE;CN=""" & emailto & """;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:" & emailto & vbCrLf
strICS = strICS & "ORGANIZER:MAILTO:" & emailto & vbCrLf
strICS = strICS & "DTSTART:" & ICSDate(IsoDate(StartDate)) & vbCrLf
strICS = strICS & "DTEND:" & ICSDate(IsoDate(EndDate)) & vbCrLf
strICS = strICS & "LOCATION:" & sLocation & vbCrLf
strICS = strICS & "TRANSP:OPAQUE" & vbCrLf
strICS = strICS & "SEQUENCE:0" & vbCrLf
strICS = strICS & "UID:" & sbooker & vbCrLf
strICS = strICS & "DTSTAMP:20060626T104103Z" & vbCrLf
strICS = strICS & "SUMMARY:" & sSubject & vbCrLf
strICS = strICS & "PRIORITY:5" & vbCrLf
strICS = strICS & "CLASS:pUBLIC" & vbCrLf
strICS = strICS & "BEGIN:VALARM" & vbCrLf
strICS = strICS & "TRIGGER:pT15M" & vbCrLf
strICS = strICS & "ACTION:DISPLAY" & vbCrLf
strICS = strICS & "DESCRIPTION:Reminder" & vbCrLf
strICS = strICS & "END:VALARM" & vbCrLf
strICS = strICS & "END:VEVENT" & vbCrLf
strICS = strICS & "END:VCALENDAR" & vbCrLf
'Write it to a file
Dim a As System.IO.StreamWriter = _
System.IO.File.CreateText(Application.StartupPath & "\" & ICS_ID & ".ics")
a.Write(strICS)
a.Close()
Dim MailTo As String
'Set the SMTP Server
smtpMail.SmtpServer = txtSMTPServer.Text
'Create the Attachment
Dim MailAttachment As New System.Web.Mail.MailAttachment(Application.StartupPath & "\" & ICS_ID & ".ics")
'MailMessage. = txtSMTPServer.Text
MailMessage.From = GetUserEmail(sbooker)
If Trim(MailMessage.From) = "" Then
MailMessage.From = txtFallbackFrom.Text
End If
MailTo = Trim(GetUserEmail(emailto) & ";" & GetAttendeeEmails(Res_id))
If Microsoft.VisualBasic.Left(MailTo.Trim, 1) = ";" Then
MailTo = Mid(MailTo, 2, Len(MailTo))
End If
'MailMessage.To = MailTo.Trim
MailMessage.Subject = sSubject
'MailMessage.Headers()
MailMessage.Body = strICS 'Substitute_Tags(GetInvitationBody(), Res_id)
'MailMessage.Attachments.Add(MailAttachment)
MailMessage.BodyEncoding = System.Text.Encoding.UTF7
MailMessage.BodyFormat = MailFormat.Text
'Content-Type: text/calendar; method=REQUEST;charset = "utf-8"
'Content-Transfer-Encoding: 7bit
MailMessage.Headers.Add("Content-Type", "text/calendar; method=REQUEST;")
MailMessage.Headers.Add("Content-Transfer-Encoding", "7bit")

In theory the two lines I have boldened at the end should cause the mail client to treat the e-mail like a meeting invite and so interperet the ICS content however the e-mail is being treated like a standard e-mail and so the ICS text is just appearing literally.

Can any of you e-mail buffs tell me if there is anything else I need to do to get Lotus to treat this like a meeting invite rather than a standard e-mail?

Any help is as always greatly appreciated.

Cheers,

Chris

P.s. Interestingly when the e-mail is received the header info for the e-mail does not show the encoding that I have added.. ????
 
Back
Top