async void SendEmailAfterRepairCompleted() { string currentDateString = DateTime.Now.ToString("MM/dd/yyyy"); string[] to = new string[] { CurrentIncident.GetProperty().GetEmail() }; string[] cc = new string[] { Constants.DISPATCHEREMAIL }; string subject = string.Format("Repair Report - {0} - {1}", CurrentIncident.GetProperty().GetTitle(), currentDateString); string body = string.Format("The incident found during a recent inspection on you property has been repaired. Photographs taken during the inspection and after the repair are attached to this email." + "<br/>" + "<br/><b>Property Name:</b> {0}" + "<br/><b>Property Address:</b> {1}" + "<br/>" + "<br/><b>Inspection Date:</b> {2}" + "<br/><b>Incident Type:</b> {3}" + "<br/><b>Room:</b> {4}" + "<br/><b>Comments from the inspector:</b><br/>{5}" + "<br/><br/><b>Incident reported:</b> {6}" + "<br/>" + "<br/><b>Repair Date:</b> {7}" + "<br/><b>Comments from repair person:</b><br/>{8}" + "<br/>" + "<br/><b>Attachments:</b>(Inspection & Repair Photos) - Email attachments are not supported at this time in Xamarin app, therefore no files are attached." + "<br/>" + "", CurrentIncident.GetProperty().GetTitle(), CurrentIncident.GetProperty().GetAddress1(), CurrentIncident.GetInspection().GetDateTime(), CurrentIncident.GetType(), CurrentIncident.GetRoom().GetTitle(), CurrentIncident.GetInspectorIncidentComments(), CurrentIncident.GetDate(), currentDateString, CurrentIncident.GetRepairComments()); bool success = await ExchangeHelper.SendEmail(subject, to, cc, body); }
async Task SendEmailAfterRepairCompleted() { var recipient = new Recipient { EmailAddress = new EmailAddress { Address = CurrentIncident.GetProperty().GetEmail() } }; var dispatcherRecipient = new Recipient { EmailAddress = new EmailAddress { Address = Constants.DISPATCHEREMAIL } }; var subject = string.Format("Repair Report - {0} - {1:MM/dd/yyyy}", CurrentIncident.GetProperty().GetTitle(), DateTime.Now); var body = string.Format("The incident found during a recent inspection on you property has been repaired. Photographs taken during the inspection and after the repair are attached to this email." + "<br/>" + "<br/><b>Property Name:</b> {0}" + "<br/><b>Property Address:</b> {1}" + "<br/>" + "<br/><b>Inspection Date:</b> {2}" + "<br/><b>Incident Type:</b> {3}" + "<br/><b>Room:</b> {4}" + "<br/><b>Comments from the inspector:</b><br/>{5}" + "<br/><br/><b>Incident reported:</b> {6}" + "<br/>" + "<br/><b>Repair Date:</b> {7:MM/dd/yyyy}" + "<br/><b>Comments from repair person:</b><br/>{8}" + "<br/>" + "<br/><b>Attachments:</b>(Inspection & Repair Photos) - Email attachments are not supported at this time in Xamarin app, therefore no files are attached." + "<br/>" + "<p>Incident ID: <span id='x_IncidentID'>{9}</span></p>" + "<p>Property ID: <span id='x_PropertyID'>{10}</span></p>", CurrentIncident.GetProperty().GetTitle(), CurrentIncident.GetProperty().GetAddress1(), CurrentIncident.GetInspection().GetDateTime(), CurrentIncident.GetType(), CurrentIncident.GetRoom().GetTitle(), CurrentIncident.GetInspectorIncidentComments(), CurrentIncident.GetDate(), DateTime.Now, CurrentIncident.GetRepairComments(), CurrentIncident.GetId(), CurrentIncident.GetProperty().GetId() ); var message = new Microsoft.Graph.Message { ToRecipients = new [] { recipient }, CcRecipients = new [] { dispatcherRecipient }, Subject = subject, Body = new ItemBody { Content = body, ContentType = BodyType.HTML } }; process = ProgressDialog.Show(this, "Processing", "Sending email..."); //Currently, the following 2 lines of code must be executed before the SendMailAsync //method is called. If the call the return the user's photo is not executed //the SendMailAsync method will not successfully send the email. This is a known //issue and this sample will be adjusted accordingly once this issue is resolved. var photo = await App.GraphService.Me.UserPhoto.ExecuteAsync(); var pid = photo.Id.ToString(); await App.GraphService.Me.SendMailAsync(message, true); process.Dismiss(); }
async Task SendEmailAfterRepairCompleted() { var graphToken = await AuthenticationHelper.GetGraphAccessTokenAsync(this); var recipient = CurrentIncident.GetProperty().GetEmail(); var dispatcherRecipient = Constants.DISPATCHEREMAIL; var subject = string.Format("Repair Report - {0} - {1:MM/dd/yyyy}", CurrentIncident.GetProperty().GetTitle(), DateTime.Now); var bodyContent = string.Format("The incident found during a recent inspection on you property has been repaired. Photographs taken during the inspection and after the repair are attached to this email." + "<br/>" + "<br/><b>Property Name:</b> {0}" + "<br/><b>Property Address:</b> {1}" + "<br/>" + "<br/><b>Inspection Date:</b> {2}" + "<br/><b>Incident Type:</b> {3}" + "<br/><b>Room:</b> {4}" + "<br/><b>Comments from the inspector:</b><br/>{5}" + "<br/><br/><b>Incident reported:</b> {6}" + "<br/>" + "<br/><b>Repair Date:</b> {7:MM/dd/yyyy}" + "<br/><b>Comments from repair person:</b><br/>{8}" + "<br/>" + "<br/><b>Attachments:</b>(Inspection & Repair Photos) - Email attachments are not supported at this time in Xamarin app, therefore no files are attached." + "<br/>" + "<p>Incident ID: <span id='x_IncidentID'>{9}</span></p>" + "<p>Property ID: <span id='x_PropertyID'>{10}</span></p>", CurrentIncident.GetProperty().GetTitle(), CurrentIncident.GetProperty().GetAddress1(), CurrentIncident.GetInspection().GetDateTime(), CurrentIncident.GetType(), CurrentIncident.GetRoom().GetTitle(), CurrentIncident.GetInspectorIncidentComments(), CurrentIncident.GetDate(), DateTime.Now, CurrentIncident.GetRepairComments(), CurrentIncident.GetId(), CurrentIncident.GetProperty().GetId() ); var message = new Microsoft.Graph.Message { Subject = subject, Body = new ItemBody { ContentType = BodyType.Html, Content = bodyContent }, ToRecipients = new Recipient[] { new Recipient { EmailAddress = new EmailAddress { Address = dispatcherRecipient } } }, CcRecipients = new Recipient[] { new Recipient { EmailAddress = new EmailAddress { Address = recipient } } } }; var requestBuilder = App.GraphService.Me.SendMail(message, true); var request = requestBuilder.Request(); request.ContentType = "application/json"; request.Headers.Add(new HeaderOption("Authorization", "Bearer " + graphToken)); process = ProgressDialog.Show(this, "Processing", "Sending email..."); await request.PostAsync(); process.Dismiss(); }