/// <summary> /// SendEmailAsync /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SendMailResponse> SendEmailAsync(ISendMailRequest request) { var messageResponse = new SendMailResponse(); var messageModel = BuildEmailMessage(request); try { if (string.IsNullOrWhiteSpace(_token)) { await GetAuthenticationDetailAsync(); } if (_client == null) { _client = GetGmailClient(); } var result = await _client.Users.Messages.Send(messageModel, "me").ExecuteAsync(); messageResponse.IsSuccess = true; } catch (Exception ex) { messageResponse.ErrorMessage = ex.Message; } return(messageResponse); }
/// <summary> /// Sends MIME-formatted e-mail messages to the server. /// </summary> /// <param name="request">A SendMailRequest object that contains the request information.</param> /// <returns>A SendMailResponse object.</returns> public SendMailResponse SendMail(SendMailRequest request) { SendMailResponse response = this.activeSyncClient.SendMail(request); Site.Assert.IsNotNull(response, "If the SendMail command executes successfully, the response from server should not be null."); return(response); }
public SendMailResponse Send(SendMailRequest request) { Logger.Current.Verbose("VmtaMailService > Send - Subject: " + request.Subject); SendMailResponse response = new SendMailResponse(); try { var result = SendEmail(request.Subject, request.Body, request.To, request.CC, request.BCC , request.From, request.ServiceProviderEmail, request.DisplayName, request.AccountDomain, request.AttachmentGUID, request.NotificationAttachementGuid, request.NightlyAttachmentGUIDS, request.MergeValues); Logger.Current.Verbose("VmtaMailService > Send - Subject: " + request.Subject); response.StatusID = result ? CommunicationStatus.Success : CommunicationStatus.Failed; if (response.StatusID == CommunicationStatus.Success) { Logger.Current.Verbose("Email sent successfully with subject: " + request.Subject); response.ServiceResponse = "Email sent successfully"; } else { Logger.Current.Verbose("Email failed with subject: " + request.Subject); response.ServiceResponse = "Email failed"; } response.RequestGuid = request.RequestGuid == Guid.Empty ? Guid.NewGuid() : request.RequestGuid; } catch (Exception ex) { Logger.Current.Error("Exception occured while sending email: " + ex); response.ServiceResponse = ex.Message; response.StatusID = CommunicationStatus.Failed; } return(response); }
/// <summary> /// The method is used to send a mail /// </summary> /// <param name="emailType">The type of the email.</param> /// <param name="subject">The subject of the mail.</param> /// <param name="body">The body of the item.</param> protected void SendEmail(EmailType emailType, string subject, string body) { SendMailRequest request = new SendMailRequest { RequestData = { ClientId = Guid.NewGuid().ToString("N"), Mime = TestSuiteHelper.CreateMIME( emailType, Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain), Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain), subject, body) } }; SendMailResponse sendMailResponse = this.ASAIRSAdapter.SendMail(request); this.Site.Assert.AreEqual <string>( string.Empty, sendMailResponse.ResponseDataXML, "The server should return an empty XML body to indicate SendMail command is executed successfully."); this.SwitchUser(this.User2Information, true); this.RecordCaseRelativeItems(this.User2Information.UserName, this.User2Information.InboxCollectionId, subject); }
public SendMailResponse SendCreationMail(SendMailRequest request) { var response = new SendMailResponse { ResponseStatus = ResponseStatus.Success }; var creationsProvider = new CreationsProvider(); try { if (request.ActionType == ActionType.Update) { response.IsSucessful = creationsProvider.ExecuteSendingMail(request); } else { response.ResponseStatus = ResponseStatus.Failure; response.ResponseDescription = "Not update action"; } } catch (Exception ex) { response.ResponseStatus = ResponseStatus.Failure; response.ResponseDescription = ex.Message; } return(response); }
public SendMailResponse Send(SendMailRequest request) { SendMailResponse result = new SendMailResponse(); try { result.RequestGuid = Guid.NewGuid(); smtpClient.Send(request.ToMailMessage()); SendMailDetail details = new SendMailDetail(); details.BCC = string.IsNullOrEmpty(Convert.ToString(request.BCC)) ? null : string.Join(";", request.BCC.ToArray()); details.CC = string.IsNullOrEmpty(Convert.ToString(request.CC)) ? null : string.Join(";", request.CC.ToArray()); details.From = request.From; details.Status = CommunicationStatus.Success; details.To = string.Join(";", request.To.ToArray()); result.Details.Add(details); Response mailresponse = new Response(); result.RequestGuid = mailresponse.MailResponse(result); } catch (Exception ex) { Logger.Current.Error("Exception occurred sending the mail..", ex); } return(result); }
/// <summary> /// SendEmailAsync /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SendMailResponse> SendEmailAsync(ISendMailRequest request) { var messageResponse = new SendMailResponse(); var messageModel = BuildEmailMessage(request); try { if (string.IsNullOrWhiteSpace(_token)) { await GetAuthenticationDetailAsync(); } if (_client == null) { _client = new GraphServiceClient(new DelegateAuthenticationProvider(async requestMessage => { requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", _token); })); } await _client.Me.SendMail(messageModel, true).Request().PostAsync(); messageResponse.IsSuccess = true; } catch (Exception ex) { messageResponse.ErrorMessage = ex.Message; } return(messageResponse); }
public void MSASCMD_S21_TC01_CommonStatusCode_166() { Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Status value 166 is not returned when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Status value 166 is not returned when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion."); #region Call method SendMail to send e-mail messages with invalid AccountID value. string emailSubject = Common.GenerateResourceName(Site, "subject"); // Send email with invalid AccountID value SendMailResponse sendMailResponse = this.SendPlainTextEmail("InvalidAccountID", emailSubject, this.User1Information.UserName, this.User2Information.UserName, null); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4956"); Site.Log.Add(LogEntryKind.Debug, "When sending mail with invalid AccountID, server returns status {0}", sendMailResponse.ResponseData.Status); // Verify MS-ASCMD requirement: MS-ASCMD_R4956 Site.CaptureRequirementIfAreEqual <string>( "166", sendMailResponse.ResponseData.Status, 4956, @"[In Common Status Codes] [The meaning of the status value 166 is] The AccountId (section 2.2.3.3) value is not valid.<100>"); #region Sync user2 mailbox changes // Switch to user2's mailbox this.SwitchUser(this.User2Information); this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject); // Record user name, folder collectionId and item subject that is used in this case TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject); #endregion }
/// <summary> /// Send a plain text email. /// </summary> /// <param name="subject">The subject of email</param> /// <param name="cc">The cc address of the mail</param> /// <param name="bcc">The bcc address of the mail</param> protected void SendPlaintextEmail(string subject, string cc, string bcc) { string emailBody = Common.GenerateResourceName(Site, "content"); string emailMime = TestSuiteHelper.CreatePlainTextMime( Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain), Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain), cc, bcc, subject, emailBody); string clientId = TestSuiteHelper.GetClientId(); SendMailRequest sendMailRequest = TestSuiteHelper.CreateSendMailRequest(clientId, false, emailMime); this.SwitchUser(this.User1Information, false); SendMailResponse response = this.EMAILAdapter.SendMail(sendMailRequest); Site.Assert.AreEqual <string>( string.Empty, response.ResponseDataXML, "The server should return an empty xml response data to indicate SendMail command executes successfully."); this.SwitchUser(this.User2Information, true); this.RecordCaseRelativeItems(this.User2Information.UserName, this.User2Information.InboxCollectionId, subject); }
/// <summary> /// Send a meeting response email /// </summary> /// <param name="calendar">The meeting calendar</param> protected void SendMeetingResponse(Calendar calendar) { // Create reply mail to organizer string emailBody = Common.GenerateResourceName(Site, "content"); string icalendarResponseContent = TestSuiteHelper.CreateMeetingResponseiCalendarFormatContent( (DateTime)calendar.DtStamp, (DateTime)calendar.EndTime, calendar.UID, calendar.Subject, calendar.Location, calendar.OrganizerEmail, calendar.Attendees.Attendee[0].Email); // Create reply mail mime content string meetingResponseEmailMime = TestSuiteHelper.CreateMeetingRequestMime( calendar.Attendees.Attendee[0].Email, calendar.OrganizerEmail, calendar.Subject, emailBody, icalendarResponseContent); string clientId = TestSuiteHelper.GetClientId(); SendMailRequest sendMailRequest = TestSuiteHelper.CreateSendMailRequest(clientId, false, meetingResponseEmailMime); this.SwitchUser(this.User2Information, true); SendMailResponse response = this.EMAILAdapter.SendMail(sendMailRequest); Site.Assert.AreEqual <string>( string.Empty, response.ResponseDataXML, "The server should return an empty xml response data to indicate SendMail command success."); }
public async Task <SendMailResponse> SendMail(string to, string subject, string body) { var SendMail = Configuration["url"]; SendMailResponse response = await _httlClient.PostJsonAsync <SendMailResponse>(SendMail + "Email/SendMail", new SendMailRequest(to, subject, body)); return(response); }
/// <summary> /// Send a plain text email. /// </summary> /// <param name="subject">The subject of email</param> /// <param name="cc">The cc address of the mail</param> /// <param name="bcc">The bcc address of the mail</param> /// <param name="to">The to address of the mail</param> /// <param name="sender">The sender address of the mail</param> /// <param name="replyTo">The replyTo address of the mail</param> /// <param name="from">The from address of the mail</param> protected void SendPlaintextEmail( string subject, string cc, string bcc, string to, string sender, string replyTo, string from) { string emailBody = Common.GenerateResourceName(Site, "content"); string emailMime = TestSuiteHelper.CreatePlainTextMime( string.IsNullOrEmpty(from) ? Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain) : from, string.IsNullOrEmpty(to) ? Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain) : to, cc, bcc, subject, emailBody, sender, replyTo); string clientId = TestSuiteHelper.GetClientId(); SendMailRequest sendMailRequest = TestSuiteHelper.CreateSendMailRequest(clientId, false, emailMime); this.SwitchUser(this.User1Information, false); SendMailResponse response = this.EMAILAdapter.SendMail(sendMailRequest); Site.Assert.AreEqual <string>( string.Empty, response.ResponseDataXML, "The server should return an empty xml response data to indicate SendMail command was executed successfully."); }
/// <summary> /// Call SendMail command to send mail. /// </summary> /// <param name="from">The mailbox address of sender.</param> /// <param name="to">The mailbox address of recipient.</param> /// <param name="subject">The subject of the email.</param> /// <param name="body">The body content of the email.</param> protected void CallSendMailCommand(string from, string to, string subject, string body) { if (string.IsNullOrEmpty(body)) { body = Common.GenerateResourceName(this.Site, "body"); } // Create the SendMail command request. string template = @"From: {0} To: {1} Subject: {2} Content-Type: text/html; charset=""us-ascii"" MIME-Version: 1.0 <html> <body> <font color=""blue"">{3}</font> </body> </html> "; string mime = Common.FormatString(template, from, to, subject, body); SendMailRequest sendMailRequest = Common.CreateSendMailRequest(null, System.Guid.NewGuid().ToString(), mime); // Call SendMail command. SendMailResponse sendMailResponse = this.CONAdapter.SendMail(sendMailRequest); Site.Assert.AreEqual(string.Empty, sendMailResponse.ResponseDataXML, "The SendMail command should be executed successfully."); }
public JsonResult SendMail(string sendMailViewModel) { SendMailViewModel viewModel = JsonConvert.DeserializeObject <SendMailViewModel>(sendMailViewModel); if (!string.IsNullOrEmpty(viewModel.Body)) { viewModel.Body = ReplacingSpecialCharacterWithTheirCode(viewModel.Body); viewModel.Body = viewModel.Body.Replace("&", "&"); } var accountId = this.Identity.ToAccountID(); var userId = this.Identity.ToUserID(); viewModel.AccountID = accountId; SendMailRequest request = new SendMailRequest() { SendMailViewModel = viewModel, AccountId = accountId, RequestedBy = userId, UserName = viewModel.SenderName, AccountDomain = Request.Url.Host }; SendMailResponse response = communicationService.SendMail(request); if (response.ResponseMessage == CommunicationStatus.Success) { return(Json(new { success = true, response = "[|Sent successfully|]" }, JsonRequestBehavior.AllowGet)); } else { throw new UnsupportedOperationException("[|Send Failure|]", response.Exception); } }
public Guid MailResponse(SendMailResponse request) { CMDataAccess datatAccess = new CMDataAccess(); MailResponse requestData = new MailResponse(); if (request != null) { requestData.RequestGuid = request.RequestGuid; requestData.Token = request.Token; requestData.CreatedDate = DateTime.Now; MailResponseDetails mailresponsedetails = null; foreach (var varItem in request.Details) { mailresponsedetails = new MailResponseDetails(); mailresponsedetails.MailGuid = varItem.MailGuid; mailresponsedetails.To = varItem.To; mailresponsedetails.From = varItem.From; mailresponsedetails.CC = varItem.CC; mailresponsedetails.BCC = varItem.BCC; mailresponsedetails.Status = varItem.Status; mailresponsedetails.ServiceResponse = varItem.ServiceResponse; mailresponsedetails.CreatedDate = DateTime.Now; mailresponsedetails.MailResponse = requestData; requestData.MailResponseDetails.Add(mailresponsedetails); } return(datatAccess.MailResponse(requestData)); } return(Guid.NewGuid()); }
/// <summary> /// Send a meeting request email. /// </summary> /// <param name="subject">The subject of email</param> /// <param name="calendar">The meeting calendar</param> private void SendMeetingRequest(string subject, Calendar calendar) { string emailBody = Common.GenerateResourceName(Site, "content"); string icalendarFormatContent = TestSuiteHelper.CreateiCalendarFormatContent(calendar); string meetingEmailMime = TestSuiteHelper.CreateMeetingRequestMime( calendar.OrganizerEmail, calendar.Attendees.Attendee[0].Email, subject, emailBody, icalendarFormatContent); Request.SendMail sendMail = new Request.SendMail(); sendMail.ClientId = Guid.NewGuid().ToString("N"); sendMail.Mime = meetingEmailMime; SendMailRequest sendMailRequest = Common.CreateSendMailRequest(); sendMailRequest.RequestData = sendMail; this.SwitchUser(this.User1Information, false); SendMailResponse response = this.ASAIRSAdapter.SendMail(sendMailRequest); Site.Assert.AreEqual <string>( string.Empty, response.ResponseDataXML, "The server should return an empty xml response data to indicate SendMail command success."); }
/// <summary> /// SendEmailAsync /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SendMailResponse> SendEmailAsync(ISendMailRequest request) { var messageResponse = new SendMailResponse(); var requestedServerVersion = (ExchangeVersion)_clientConfig.HostClientRequestInfo.Port; ExchangeService service = new ExchangeService(requestedServerVersion); service.Credentials = _webCrendential; service.Url = new Uri(_clientConfig.HostClientRequestInfo.Host); EmailMessage message = new EmailMessage(service) { From = new EmailAddress(request.FromName, request.From), Subject = request.Subject }; message.ToRecipients.Add(request.Recipients.First()); message.Body = request.Message; ExtendedPropertyDefinition customHeaders; foreach (var header in request.Headers) { if (header.Key.Equals("List-Unsubscribe", StringComparison.OrdinalIgnoreCase)) { customHeaders = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, header.Key, MapiPropertyType.String); var splitValues = header.Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (splitValues.Length > 1) { message.SetExtendedProperty(customHeaders, splitValues[0]); } else { message.SetExtendedProperty(customHeaders, header.Value); } } else { customHeaders = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, header.Key, MapiPropertyType.String); message.SetExtendedProperty(customHeaders, header.Value); } } try { await message.SendAndSaveCopy(); messageResponse.IsSuccess = true; } catch (Exception ex) { messageResponse.ErrorMessage = ex.Message; } return(messageResponse); }
/// <summary> /// Using mail with mime content to send a meeting request or cancel request /// </summary> /// <param name="calendarItem">Calendar information</param> /// <param name="subjectName">The subject name of meeting request mail</param> /// <param name="organizerEmailAddress">The organizer email address</param> /// <param name="attendeeEmailAddress">The attendee email address</param> /// <param name="method">Specify normal appointments from meeting requests, responses, and cancellations, it can be set to 'REQUEST', 'REPLY', or 'CANCEL'</param> /// <param name="replyMethod">Specify REPLY method, it can be set to 'ACCEPTED', 'TENTATIVE', or 'DECLINED'</param> protected void SendMimeMeeting(Calendar calendarItem, string subjectName, string organizerEmailAddress, string attendeeEmailAddress, string method, string replyMethod) { string icalendarContent = string.Empty; switch (method.ToUpper(CultureInfo.CurrentCulture)) { case "REQUEST": case "CANCEL": icalendarContent = TestSuiteHelper.CreateiCalendarFormatContent(calendarItem, method, replyMethod, organizerEmailAddress, attendeeEmailAddress); break; case "REPLY": icalendarContent = TestSuiteHelper.CreateiCalendarFormatContent(calendarItem, method, replyMethod, attendeeEmailAddress, organizerEmailAddress); break; } string body = string.Empty; string mime = TestSuiteHelper.CreateMeetingRequestMime( organizerEmailAddress, attendeeEmailAddress, subjectName, body, icalendarContent); // Send a meeting request SendMailRequest sendMailRequest = TestSuiteHelper.CreateSendMailRequest(TestSuiteHelper.Next(), false, mime); SendMailResponse sendMailResponse = this.CALAdapter.SendMail(sendMailRequest); Site.Assert.AreEqual <string>( string.Empty, sendMailResponse.ResponseDataXML, "The server should return an empty xml response data to indicate SendMail command success."); }
/// <summary> /// SendEmailAsync /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SendMailResponse> SendEmailAsync(ISendMailRequest request) { var response = new SendMailResponse(); try { if (_client == null) { _client = new SendGridClient(_clientConfig.ApiKey); } var recipientList = request.Recipients.Select(recipient => new EmailAddress(recipient)).ToList(); var from = new EmailAddress(request.From, request.FromName); var plainTextContent = HtmlText.ConvertHtml(request.Message); var htmlContent = request.Message; var msg = MailHelper.CreateSingleEmailToMultipleRecipients(from, recipientList, request.Subject, plainTextContent, htmlContent); await _client.SendEmailAsync(msg); } catch (Exception ex) { response.ErrorMessage = ex.Message; response.IsSuccess = false; } return(response); }
/// <summary> /// Sends MIME-formatted e-mail messages to the server. /// </summary> /// <param name="sendMailRequest">The request for SendMail command.</param> /// <returns>The SendMail response which is returned from server.</returns> public SendMailResponse SendMail(SendMailRequest sendMailRequest) { SendMailResponse response = this.activeSyncClient.SendMail(sendMailRequest); Site.Assert.IsNotNull(response, "If the command is successful, the response should not be null."); return(response); }
public async Task <SendMailResponse> SendMail(SendMailRequest o) { var result = new SendMailResponse(o.RequestId); result.Id = await Server.SendEmail(o.Application, o.From, o.To, o.Cc, o.Bcc, o.Subject, o.Body, o.Html); return(result); }
/// <summary> /// Sends MIME-formatted e-mail messages to the server. /// </summary> /// <param name="sendMailRequest">A SendMailRequest object that contains the request information.</param> /// <returns>SendMail command response.</returns> public SendMailResponse SendMail(SendMailRequest sendMailRequest) { SendMailResponse sendMailResponse = this.activeSyncClient.SendMail(sendMailRequest); Site.Assert.IsNotNull(sendMailResponse, "The SendMail response returned from server should not be null."); return(sendMailResponse); }
public void SendMail_Success(string name) { SendMail request = PrepareRequest <SendMail>(name); SendMailResponse response = Post <SendMail, SendMailResponse>("SendMail", request); Assert.IsTrue(response.Success, "Failed to send email"); }
/// <summary> /// Sends MIME-formatted e-mail messages to the server. /// </summary> /// <param name="sendMailRequest">The request for SendMail operation.</param> /// <returns>The SendMail response which is returned from the server.</returns> public SendMailResponse SendMail(SendMailRequest sendMailRequest) { SendMailResponse response = this.activeSyncClient.SendMail(sendMailRequest); Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null."); this.VerifyTransport(); return(response); }
public SendMailResponse SendIndependent(SendMailRequest request) { var result = new SendMailResponse { RequestGuid = Guid.NewGuid() }; smtpClient.Send(request.ToMailMessage()); return(result); }
/// <summary> /// Sends MIME-formatted e-mail messages to the server. /// </summary> /// <param name="request">A SendMailRequest object that contains the request information.</param> /// <returns>SendMail command response</returns> public SendMailResponse SendMail(SendMailRequest request) { SendMailResponse response = this.activeSyncClient.SendMail(request); this.VerifyTransportRequirements(); this.VerifyWBXMLCapture(CommandName.SendMail, response); this.VerifySendMailCommand(response); return(response); }
public ResponseBase Any(CreateAccount request) { _logger.Log(EErrorType.Info, " ****** Call start: CreateAccount"); CreateAccountResponse response = new CreateAccountResponse(); try { GetUserAccountInfoParams accParams = new GetUserAccountInfoParams(); accParams.Email = request.Email; GetUserAccountInfoResult accResult = _dal.GetUserAccountInfo(accParams); if (accResult == null) { // creating account CreateUpdateUserAccountParams createParams = new CreateUpdateUserAccountParams(); createParams.Name = request.Name; createParams.Email = request.Email; createParams.AccountKey = EncodeUtils.CreateAccountKey(); createParams.PwdHash = EncodeUtils.GetPasswordHash(request.Pwd); createParams.ActivationCode = EncodeUtils.CreateActivationCode(); createParams.State = "Pending"; // TODO; change to consts _dal.CreateUserAccount(createParams); SendMailResponse mailerResponse = SendAccountConfirmEmail(createParams.Email, createParams.AccountKey, createParams.Name); response.Payload.AccountKey = createParams.AccountKey; response.Success = true; } else { response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.UserAccountExists, Type = EErrorType.Error, Message = "User with specified data already exists" }); } } catch (Exception ex) { _logger.Log(ex); response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unexpected error: {0}", ex.Message) }); } _logger.Log(EErrorType.Info, " ****** Call end: CreateAccount"); return(response); }
public SendMailResponse Send(SendMailRequest request) { if (provider == MailProvider.Smtp) { var failedRecipients = new List <string>(); var requests = new List <MailMessage>(); var campaignReceipients = request.CampaignReceipients; while (campaignReceipients.Any()) { var message = new MailMessage(); message.From = new MailAddress(request.From, request.DisplayName); message.Subject = request.Subject; message.IsBodyHtml = true; var campaignReceipient = campaignReceipients.First(); try { var campaignBody = request.Body.Replace("*|CRID|*", campaignReceipient.CampaignRecipientID.ToString()); message.To.Add(campaignReceipient.EmailId); string MergeStringContent = campaignBody; if (campaignReceipient.ContactInfo != null) { MergeStringContent = ReplaceMergeFields(campaignBody, campaignReceipient.ContactInfo); } message.Body = MergeStringContent; requests.Add(message); } catch (Exception ex) { Logger.Current.Error("Error while adding recipient " + campaignReceipient.EmailId + " to list. Hence skipped. Error: ", ex); failedRecipients.Add(campaignReceipient.EmailId); } campaignReceipients = campaignReceipients.Skip(1).ToList(); } SendMailResponse sendMailResponse = SmtpSend(registration.Guid, requests); failedRecipients.AddRange(sendMailResponse.FailedRecipients); sendMailResponse.FailedRecipients = failedRecipients; return(sendMailResponse); } else { return(SmtpSend(registration.Guid, request)); } }
private SendMailResponse SendPasswordChangedNotificationEmail(string email, string userName) { SendMailResponse result = null; MailDetails datails = new MailDetails(); datails.MessageType = "PasswordChangedConfirmation"; datails.ToAddress = email; datails.Parameters.Add("UserName", userName); SendMail sendMailRequest = new SendMail(); sendMailRequest.SessionToken = ConfigurationManager.AppSettings["MailServiceSessionToken"]; sendMailRequest.Details.Add(datails); Client.Mail.ServiceClient client = new Client.Mail.ServiceClient(); result = client.PostSendMail(sendMailRequest); return(result); }
/// <summary> /// Call SendMail command to send one voice email /// </summary> /// <param name="emailSubject">Email subject</param> /// <param name="firstVoiceFilePath">First voice attachment file name</param> /// <param name="secondVoiceFilePath">Second voice attachment file name</param> /// <returns>Email item</returns> private Sync SendVoiceMail(string emailSubject, string firstVoiceFilePath, string secondVoiceFilePath) { // Create mail content string senderEmail = Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain); string receiverEmail = Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain); string emailBody = Common.GenerateResourceName(Site, "content"); string callNumber = "7125550123"; // Create voice mail content mime string voiceMailMime = TestSuiteHelper.CreateVoiceAttachmentMime( senderEmail, receiverEmail, emailSubject, emailBody, callNumber, firstVoiceFilePath, secondVoiceFilePath); string clientId = TestSuiteHelper.GetClientId(); SendMailRequest sendMailRequest = TestSuiteHelper.CreateSendMailRequest(clientId, false, voiceMailMime); SendMailResponse response = this.EMAILAdapter.SendMail(sendMailRequest); // Verify send voice mail success Site.Assert.AreEqual <string>( string.Empty, response.ResponseDataXML, "The server should return an empty xml response data to indicate SendMail command executes successfully.", response.ResponseDataXML); #region Record user name, folder collectionId and item subject that are used in this case. this.SwitchUser(this.User2Information, true); this.RecordCaseRelativeItems(this.User2Information.UserName, this.User2Information.InboxCollectionId, emailSubject); #endregion #region Sync changes in user2 mailbox . // Sync changes SyncStore result = this.GetSyncResult(emailSubject, this.User2Information.InboxCollectionId, null); Sync emailItem = TestSuiteHelper.GetSyncAddItem(result, emailSubject); #endregion return(emailItem); }
/// <summary> /// This method is used to verify the SendMail response related requirements. /// </summary> /// <param name="sendMailResponse">SendMail command response.</param> private void VerifySendMailCommand(SendMailResponse sendMailResponse) { Site.Assert.IsTrue(this.activeSyncClient.ValidationResult, "The schema validation result should be true."); Site.Assert.IsNotNull(sendMailResponse.ResponseData, "The SendMail element should not be null."); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3887"); // If the schema validation result is true and SendMail is not null, this requirement can be verified. Site.CaptureRequirement( 3887, @"[In SendMail] The SendMail element is a required element in SendMail command requests and responses that identifies the body of the HTTP POST as containing a SendMail command (section 2.2.2.16)."); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2557"); // If the schema validation result is true and SendMail is not null, this requirement can be verified. Site.CaptureRequirement( 2557, @"[In SendMail] None [Element SendMail in SendMail command response has no parent element.]"); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2558"); // If the schema validation result is true and SendMail is not null, this requirement can be verified. Site.CaptureRequirement( 2558, @"[In SendMail] Element SendMail in SendMail command response, the child element is Status (section 2.2.3.167.13)."); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2559"); // If the schema validation result is true and SendMail is not null, this requirement can be verified. Site.CaptureRequirement( 2559, @"[In SendMail] Element SendMail in SendMail command response, the data type is container."); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2560"); // If the schema validation result is true and SendMail is not null, this requirement can be verified. Site.CaptureRequirement( 2560, @"[In SendMail] Element SendMail in SendMail command response, the number allowed is 1...1 (required)."); this.VerifyContainerDataType(); if (sendMailResponse.ResponseData.Status != null) { int status; Site.Assert.IsTrue(int.TryParse(sendMailResponse.ResponseData.Status, out status), "The Status element in SendMail response should be an integer."); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2751"); // If the schema validation result is true and Status(SendMail) is not null, this requirement can be verified. Site.CaptureRequirement( 2751, @"[In Status(SendMail)] Element Status in SendMail command response,the parent element is SendMail (section 2.2.3.152)."); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2752"); // If the schema validation result is true and Status(SendMail) is not null, this requirement can be verified. Site.CaptureRequirement( 2752, @"[In Status(SendMail)] None [Element Status in SendMail command response has no child element.]"); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2753"); // If the schema validation result is true, Status(SendMail) is an integer, this requirement can be verified. Site.CaptureRequirement( 2753, @"[In Status(SendMail)] Element Status in SendMail command response, the data type is integer ([MS-ASDTYPE] section 2.6)."); this.VerifyIntegerDataType(); // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2754"); // If the schema validation result is true and Status(SendMail) is not null, this requirement can be verified. Site.CaptureRequirement( 2754, @"[In Status(SendMail)] Element Status in SendMail command response, the number allowed is 0...1 (optional)."); } }