home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / App_Code / AppointmentVCAL.vb < prev    next >
Text File  |  2011-03-06  |  3KB  |  81 lines

  1. ∩╗┐Imports Microsoft.VisualBasic
  2. Imports System.Net.Mail
  3.  
  4. Public Class AppointmentVCAL
  5.     ' This class formats and sends a meeting request via SMTP email
  6.  
  7.     Public StartDate As DateTime
  8.     Public EndDate As DateTime
  9.     Public Subject As String
  10.     Public Summary As String
  11.     Public Location As String
  12.     Public AttendeeName As String
  13.     Public AttendeeEmail As String
  14.     Public OrganizerName As String
  15.     Public OrganizerEmail As String
  16.     Public MethodType As String
  17.  
  18.     Public Sub New(ByVal pdtStartDate As DateTime, _
  19.     ByVal pdtEndDate As DateTime, _
  20.     ByVal psSubject As String, _
  21.     ByVal psSummary As String, _
  22.     ByVal psLocation As String, _
  23.     ByVal psAttendeeName As String, _
  24.     ByVal psAttendeeEmail As String, _
  25.     ByVal psOrganizerName As String, _
  26.     ByVal psOrganizerEmail As String, _
  27.     ByVal psMethodType As String)
  28.  
  29.         ' Copy constructor parameters to public propeties
  30.  
  31.         StartDate = pdtStartDate
  32.         EndDate = pdtEndDate
  33.         Subject = psSubject
  34.         Summary = psSummary
  35.         Location = psLocation
  36.         AttendeeName = psAttendeeName
  37.         AttendeeEmail = psAttendeeEmail
  38.         OrganizerName = psOrganizerName
  39.         OrganizerEmail = psOrganizerEmail
  40.         MethodType = psMethodType
  41.     End Sub
  42.  
  43.  
  44.     Public Sub EmailAppointment()
  45.         Const c_strTimeFormat As String = "yyyyMMddTHHmmssZ"
  46.         Dim strStartTime As String = "", strEndTime As String = "", strTimeStamp As String = "", strTempStartTime As String = "", strTempEndTime As String = "", vCalendarFile As String = ""
  47.         Const VCAL_FILE As String = "BEGIN:VCALENDAR" & vbCrLf & _
  48.         "VERSION:1.0" & vbCrLf & _
  49.         "METHOD:{5}" & vbCrLf & _
  50.         "BEGIN:VEVENT" & vbCrLf & _
  51.         "DTSTART:{0}" & vbCrLf & _
  52.         "DTEND:{1}" & vbCrLf & _
  53.         "LOCATION;ENCODING=QUOTED-PRINTABLE:{2}" & vbCrLf & _
  54.         "SUMMARY;ENCODING=QUOTED-PRINTABLE:{4}" & vbCrLf & _
  55.         "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{3}" & vbCrLf & _
  56.         "TRIGGER:-PT15M" & vbCrLf & _
  57.         "PRIORITY:3" & vbCrLf & _
  58.         "END:EVENT" & vbCrLf & _
  59.         "END:VCALENDAR" & vbCrLf
  60.  
  61.         strStartTime = (DateTime.Parse(StartDate)).ToUniversalTime().ToString(c_strTimeFormat)
  62.         strEndTime = (DateTime.Parse(EndDate)).ToUniversalTime().ToString(c_strTimeFormat)
  63.  
  64.         vCalendarFile = String.Format(VCAL_FILE, strStartTime, strEndTime, Location, Summary, Subject, MethodType)
  65.  
  66.         Dim SmtpServer As New SmtpClient()
  67.         Dim Mail As New MailMessage()
  68.         SmtpServer.Credentials = New Net.NetworkCredential("prodservices", "production88")
  69.         SmtpServer.Port = 25
  70.         SmtpServer.Host = "server6"
  71.         Mail = New MailMessage
  72.         Mail.From = New MailAddress("prodservices@tfchurch.org")
  73.         Mail.To.Add(AttendeeEmail)
  74.         Mail.Subject = Subject
  75.         Mail.Body = Summary
  76.         Mail.Attachments.Add(Attachment.CreateAttachmentFromString(vCalendarFile, Subject + ".ics"))
  77.         SmtpServer.Send(Mail)
  78.     End Sub
  79.  
  80. End Class
  81.