[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] smtpMail [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Web.Mail.SmtpMail[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] MailMessage [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Web.Mail.MailMessage[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] NumSent [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ICS_ID[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strICS [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2]ICS_ID = Year(Now) & Month(Now) & Now.Day & Now.Hour & Now.Minute & Now.Second[/SIZE]
[SIZE=2][COLOR=#008000]'Create the VCARD[/COLOR][/SIZE]
[SIZE=2]strICS = "BEGIN:VCALENDAR" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "VERSION:2.0" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "METHOD:REQUEST" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "BEGIN:VEVENT" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "ATTENDEE;CN=""" & emailto & """;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:" & emailto & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "ORGANIZER:MAILTO:" & emailto & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "DTSTART:" & ICSDate(IsoDate(StartDate)) & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "DTEND:" & ICSDate(IsoDate(EndDate)) & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "LOCATION:" & sLocation & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "TRANSP:OPAQUE" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "SEQUENCE:0" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "UID:" & sbooker & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "DTSTAMP:20060626T104103Z" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "SUMMARY:" & sSubject & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "PRIORITY:5" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "CLASS:PUBLIC" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "BEGIN:VALARM" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "TRIGGER:PT15M" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "ACTION:DISPLAY" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "DESCRIPTION:Reminder" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "END:VALARM" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "END:VEVENT" & vbCrLf[/SIZE]
[SIZE=2]strICS = strICS & "END:VCALENDAR" & vbCrLf[/SIZE]
[SIZE=2][COLOR=#008000]'Write it to a file[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] a [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.IO.StreamWriter = _[/SIZE]
[SIZE=2]System.IO.File.CreateText(Application.StartupPath & "\" & ICS_ID & ".ics")[/SIZE]
[SIZE=2]a.Write(strICS)[/SIZE]
[SIZE=2]a.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] MailTo [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Set the SMTP Server[/COLOR][/SIZE]
[SIZE=2]smtpMail.SmtpServer = txtSMTPServer.Text[/SIZE]
[SIZE=2][COLOR=#008000]'Create the Attachment[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] MailAttachment [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Web.Mail.MailAttachment(Application.StartupPath & "\" & ICS_ID & ".ics")[/SIZE]
[SIZE=2][COLOR=#008000]'MailMessage. = txtSMTPServer.Text[/COLOR][/SIZE]
[SIZE=2]MailMessage.From = GetUserEmail(sbooker)[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Trim(MailMessage.From) = "" [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]MailMessage.From = txtFallbackFrom.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]MailTo = Trim(GetUserEmail(emailto) & ";" & GetAttendeeEmails(Res_id))[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Microsoft.VisualBasic.Left(MailTo.Trim, 1) = ";" [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]MailTo = Mid(MailTo, 2, Len(MailTo))[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'MailMessage.To = MailTo.Trim[/COLOR][/SIZE]
[SIZE=2]MailMessage.Subject = sSubject[/SIZE]
[SIZE=2][COLOR=#008000]'MailMessage.Headers()[/COLOR][/SIZE]
[SIZE=2]MailMessage.Body = strICS [/SIZE][SIZE=2][COLOR=#008000]'Substitute_Tags(GetInvitationBody(), Res_id)[/COLOR][/SIZE]
[SIZE=2]MailMessage.Attachments.Add(MailAttachment)[/SIZE]
[SIZE=2][B]MailMessage.BodyEncoding = System.Text.Encoding.UTF7[/B][/SIZE]
[SIZE=2][B]MailMessage.BodyFormat = MailFormat.Text[/B][/SIZE]
[SIZE=2]NumSent = Send_Emails(MailMessage, MailTo, smtpMail)[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] NumSent > 0 [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] Len(MailMessage.From.Trim) > 3 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'smtpMail.Send(MailMessage)[/COLOR][/SIZE]
[SIZE=2]CreateICS = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2]CreateICS = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]System.IO.File.Delete(Application.StartupPath & "\" & ICS_ID & ".ics")