Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net.Mail;
- using System.Text;
- using System.Web;
- namespace SRP_Demo
- {
- public class MeetingBuilder
- {
- private string sendTo;
- private string subject;
- private string location;
- private DateTime startTime;
- private DateTime endTime;
- private DateTime startDate;
- private DateTime endDate;
- public MeetingBuilder( string sendTo, string subject, string location, DateTime startTime, DateTime endTime, DateTime startDate, DateTime endDate )
- {
- this.sendTo = sendTo;
- this.subject = subject;
- this.location = location;
- this.startTime = startTime;
- this.endTime = endTime;
- this.startDate = startDate;
- this.endDate = endDate;
- }
- public string BuildHourlyMeeting()
- {
- string filePath = string.Empty;
- string path = HttpContext.Current.Server.MapPath( "~/iCal/" );
- filePath = string.Format( "{0}{1}.ics", path, subject );
- StreamWriter writer = new StreamWriter(filePath);
- writer.WriteLine( "BEGIN:VCALENDAR" );
- writer.WriteLine( "VERSION:2.0" );
- writer.WriteLine( "PRODID:-//hacksw/handcal//NONSGML v1.0//EN" );
- writer.WriteLine( "BEGIN:VEVENT" );
- string startDateTime = String.Format( "{0}T{1}", startDate.ToString( "yyyyMMdd" ), startTime.ToString( "HHmmss" ) );
- string endDateTime = String.Format( "{0}T{1}", endDate.ToString( "yyyyMMdd" ), endTime.ToString( "HHmmss" ) );
- writer.WriteLine( String.Format("DTSTART:{0}", startDateTime) );
- writer.WriteLine( String.Format("DTEND:{0}", endDateTime) );
- writer.WriteLine( String.Format("SUMMARY:{0}", subject) );
- writer.WriteLine( String.Format("LOCATION:{0}", location) );
- writer.WriteLine( "END:VEVENT" );
- writer.WriteLine( "END:VCALENDAR" );
- writer.Close();
- return filePath;
- }
- public string BuildDayMeeting()
- {
- string filePath = string.Empty;
- string path = HttpContext.Current.Server.MapPath( "~/iCal/" );
- filePath = string.Format( "{0}{1}.ics", path, subject );
- StreamWriter writer = new StreamWriter( filePath );
- writer.WriteLine( "BEGIN:VCALENDAR" );
- writer.WriteLine( "VERSION:2.0" );
- writer.WriteLine( "PRODID:-//hacksw/handcal//NONSGML v1.0//EN" );
- writer.WriteLine( "BEGIN:VEVENT" );
- string startDay = String.Format( "VALUE=DATE:{0}", startDate.ToString( "yyyyMMdd" ));
- string endDay = String.Format( "VALUE=DATE:{0}", endDate.ToString( "yyyyMMdd" ) );
- writer.WriteLine( String.Format( "DTSTART;{0}", startDay ) );
- writer.WriteLine( String.Format( "DTEND;{0}", endDay ) );
- writer.WriteLine( String.Format( "SUMMARY:{0}", subject ) );
- writer.WriteLine( String.Format( "LOCATION:{0}", location ) );
- writer.WriteLine( "END:VEVENT" );
- writer.WriteLine( "END:VCALENDAR" );
- writer.Close();
- return filePath;
- }
- public void SendMeeting()
- {
- var msg = new MailMessage();
- var smtpClient = new SmtpClient( "mail.bsasoftware.com" );
- msg.From = new MailAddress( "BSartele@bsasoftware.com" );
- msg.To.Add( "sarteleb@gmail.com" );
- msg.Subject = subject;
- Attachment attachment = new Attachment( BuildDayMeeting() );
- msg.Attachments.Add( attachment );
- smtpClient.Send( msg );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement