public void Add( int partitionId, long?emailSenderUserId, string @from, string[] to, string[] copyTo, string subject, string body, bool isBodyHtml, byte[] files) { _executor.Execute( "[dbo].[EmailMessage_Add]", new { State = EmailMessageState.New, partitionId, @from, To = EmailMessageData.Join(to), CopyTo = EmailMessageData.Join(copyTo), subject, body, isBodyHtml, files, emailSenderUserId }); }
public void ProducesExpectedMessage() { // Arrange var input = new EmailMessageData( Subject, PlainTextBody, HtmlBody, Sender, To, CC, BCC, ReplyTo, MessageTrackingId); // Act var output = _target.SerializeEmailMessageData(input); // Assert Assert.Contains(SchemaVersionKey, output.Properties.Keys); Assert.Equal(SchemaVersion1, output.Properties[SchemaVersionKey]); Assert.Contains(SchemaName, output.Properties.Keys); Assert.Equal(EmailMessageDataType, output.Properties[SchemaName]); var body = output.GetBody(); Assert.Equal(TestData.SerializedEmailMessageData1, body); }
private EmailMessage Get(EmailMessageData data) { return(new EmailMessage(data.Subject, data.Body, data.From, EmailMessageData.Split(data.To), data.EmailSenderUserId) { CopyTo = EmailMessageData.Split(data.CopyTo), Files = _serializer.Deserialize <FileHolder[]>(data.Files), IsBodyHtml = data.IsBodyHtml }); }
/// <summary> /// Send Bulk Emails Send bulk merge email. Required Access Level: SendHttp /// </summary> /// <exception cref="ElasticEmail.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="emailMessageData">Email data</param> /// <returns>ApiResponse of EmailSend</returns> public ElasticEmail.Client.ApiResponse <EmailSend> EmailsPostWithHttpInfo(EmailMessageData emailMessageData) { // verify the required parameter 'emailMessageData' is set if (emailMessageData == null) { throw new ElasticEmail.Client.ApiException(400, "Missing required parameter 'emailMessageData' when calling EmailsApi->EmailsPost"); } ElasticEmail.Client.RequestOptions localVarRequestOptions = new ElasticEmail.Client.RequestOptions(); String[] _contentTypes = new String[] { "application/json" }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; var localVarContentType = ElasticEmail.Client.ClientUtils.SelectHeaderContentType(_contentTypes); if (localVarContentType != null) { localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); } var localVarAccept = ElasticEmail.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } localVarRequestOptions.Data = emailMessageData; // authentication (apikey) required if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("X-ElasticEmail-ApiKey"))) { localVarRequestOptions.HeaderParameters.Add("X-ElasticEmail-ApiKey", this.Configuration.GetApiKeyWithPrefix("X-ElasticEmail-ApiKey")); } // make the HTTP request var localVarResponse = this.Client.Post <EmailSend>("/emails", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("EmailsPost", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
private Task EnqueueMessageAsync(EmailMessageData message) { if (message == null || !message.To.Any()) { return(Task.CompletedTask); } if (string.IsNullOrEmpty(message.HtmlBody) && string.IsNullOrEmpty(message.PlainTextBody)) { throw new ArgumentException( "No message body defined. Both plain-text and html bodies are empty.", nameof(message)); } return(_emailMessageEnqueuer.SendEmailMessageAsync(message)); }
private Task EnqueueMessageToSenderAsync(IEmailBuilder emailBuilder) { var originalRecipients = emailBuilder.GetRecipients(); if (!originalRecipients.To.Any()) { _logger.LogInformation("Cannot create message to sender as the original message has no recipients."); return(null); } if (emailBuilder.Sender == null) { throw new ArgumentException( $"No sender defined for message of type '{emailBuilder.GetType()}'.", nameof(emailBuilder.Sender)); } var plainTextBody = string.Format( CultureInfo.CurrentCulture, "You sent the following message via {0}: {1}{1}{2}", _configuration.GalleryOwner.DisplayName, Environment.NewLine, emailBuilder.GetBody(EmailFormat.PlainText)); var htmlBody = string.Format( CultureInfo.CurrentCulture, "You sent the following message via {0}: {1}{1}{2}", _configuration.GalleryOwner.DisplayName, Environment.NewLine, emailBuilder.GetBody(EmailFormat.Html)); // We do not CC or BCC anyone as we do not want to disclose the sender address // when sending a separate message (otherwise we'd just have CC-ed the sender). var messageToSender = new EmailMessageData( emailBuilder.GetSubject() + " [Sender Copy]", plainTextBody, htmlBody, sender: _configuration.GalleryOwner.Address, to: originalRecipients.ReplyTo.Select(e => e.Address).ToList(), cc: null, bcc: null, replyTo: originalRecipients.ReplyTo.Select(e => e.Address).ToList(), messageTrackingId: Guid.NewGuid()); return(_emailMessageEnqueuer.SendEmailMessageAsync(messageToSender)); }
private Task EnqueueMessageAsync(EmailMessageData message) { if (message == null || !message.To.Any()) { _logger.LogInformation("Skipping enqueueing message because it is null or has no recipients."); return(Task.CompletedTask); } if (string.IsNullOrEmpty(message.HtmlBody) && string.IsNullOrEmpty(message.PlainTextBody)) { throw new ArgumentException( "No message body defined. Both plain-text and html bodies are empty.", nameof(message)); } return(_emailMessageEnqueuer.SendEmailMessageAsync(message)); }
public void SetsDefaultTimeToLive() { // Arrange var expectedTtl = TimeSpan.FromDays(2); var input = new EmailMessageData( Subject, PlainTextBody, HtmlBody, Sender, To, CC, BCC, ReplyTo, MessageTrackingId); // Act var output = _target.SerializeEmailMessageData(input); // Assert Assert.Equal(expectedTtl, output.TimeToLive); }
private EmailMessageData Add(int partitionId) { var data = _fixture.Build <EmailMessageData>() .With(x => x.EmailSenderUserId, TestConstants.TestAdminUserId) .With(x => x.To, EmailMessageData.Join(_fixture.CreateMany <string>())) .With(x => x.CopyTo, EmailMessageData.Join(_fixture.CreateMany <string>())) .Without(x => x.Id) .Create(); _messages.Add( partitionId, data.EmailSenderUserId, data.From, EmailMessageData.Split(data.To), EmailMessageData.Split(data.CopyTo), data.Subject, data.Body, data.IsBodyHtml, data.Files); return(data); }
/// <summary> /// Send Bulk Emails Send bulk merge email. Required Access Level: SendHttp /// </summary> /// <exception cref="ElasticEmail.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="emailMessageData">Email data</param> /// <param name="cancellationToken">Cancellation Token to cancel the request.</param> /// <returns>Task of EmailSend</returns> public async System.Threading.Tasks.Task <EmailSend> EmailsPostAsync(EmailMessageData emailMessageData, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { ElasticEmail.Client.ApiResponse <EmailSend> localVarResponse = await EmailsPostWithHttpInfoAsync(emailMessageData, cancellationToken).ConfigureAwait(false); return(localVarResponse.Data); }
/// <summary> /// Send Bulk Emails Send bulk merge email. Required Access Level: SendHttp /// </summary> /// <exception cref="ElasticEmail.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="emailMessageData">Email data</param> /// <returns>EmailSend</returns> public EmailSend EmailsPost(EmailMessageData emailMessageData) { ElasticEmail.Client.ApiResponse <EmailSend> localVarResponse = EmailsPostWithHttpInfo(emailMessageData); return(localVarResponse.Data); }
private void Display_ViewSubscriptionMessage() { InitializedrpType(); TR_ViewSubscription.Visible = true; if (!(Request.QueryString["id"] == null)) { m_intSubscriptionId = Convert.ToInt64(Request.QueryString["id"]); } subscriptionmessage_data = m_refContApi.GetSubscriptionMessageById(m_intSubscriptionId); ltrViewName.Text = subscriptionmessage_data.Title; ltrViewID.Text = subscriptionmessage_data.Id.ToString(); viewContentHTML.Text = subscriptionmessage_data.Text; drpType.SelectedValue = subscriptionmessage_data.Type.GetHashCode().ToString(); literalSubject.Text = EkFunctions.HtmlEncode(subscriptionmessage_data.Subject); //----- Show the default checkbox if this is a validation email message. Also check the box according //----- to what is set in the database. If this is the default message check the box. if (subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.Verification || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.FriendInvitation || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.SiteInvitation || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.GroupInvitation || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ForumPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.NewForumTopic || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ReportForumPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.NewModeratedForumTopic || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.PrivateMessage || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.BlogComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.UserJournalComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.BlogPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.GroupBlogPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.UserJournalPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ResetPassword || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.RequestResetPassword || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.GroupBlogComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ModeratedBlogComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderCancelled || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderReceived || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderShipped || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderCompleted || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderReceivedToAdmin) { ltrDefault.Text = m_refMsg.GetMessage("Default label"); tr_defaultView.Visible = true; if (subscriptionmessage_data.DefaultMessage == 1) { chkDefault.Checked = true; } ViewSubscriptionToolBar(System.Convert.ToBoolean(subscriptionmessage_data.DefaultMessage == 1 ? true : false)); } else { tr_defaultView.Visible = false; ViewSubscriptionToolBar(false); } if (!ShowSubject(subscriptionmessage_data.Type)) { rowSubjectView.Style.Add("display", "none"); } }
private void Display_EditSubscriptionMessage() { jsSetActionFunction.Text = SetActionClientScript(); m_refContent = m_refSiteAPI.EkContentRef; var2 = m_refContent.GetEditorVariablev2_0(0, "tasks"); AutoNav.Text = ""; InitializedrpType(); TR_ViewSubscription.Visible = false; TR_AddEditSubscription.Visible = true; if (!(Request.QueryString["id"] == null)) { m_intSubscriptionId = Convert.ToInt64(Request.QueryString["id"]); } subscriptionmessage_data = m_refContApi.GetSubscriptionMessageById(m_intSubscriptionId); txtName.Text = subscriptionmessage_data.Title; ltrAddEditID.Text = subscriptionmessage_data.Id.ToString() + "<input type=\"hidden\" name=\"subscriptionID\" value=\"" + subscriptionmessage_data.Id.ToString() + "\"/>"; txtSubject.Text = subscriptionmessage_data.Subject; ctlEditor.Content = subscriptionmessage_data.Text; drpTypeAddEdit.SelectedValue = subscriptionmessage_data.Type.GetHashCode().ToString(); //----- Show the default checkbox if this is a validation email message. Also check the box according //----- to what is set in the database. If this is the default message check the box. if (subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.Verification || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.FriendInvitation || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.SiteInvitation || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.GroupInvitation || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ForumPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.NewForumTopic || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ReportForumPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.NewModeratedForumTopic || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.PrivateMessage || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.BlogComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.UserJournalComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.BlogPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.GroupBlogPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.UserJournalPost || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ResetPassword || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.RequestResetPassword || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.GroupBlogComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.ModeratedBlogComment || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderCancelled || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderReceived || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderShipped || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderCompleted || subscriptionmessage_data.Type == Ektron.Cms.Common.EkEnumeration.EmailMessageTypes.OrderReceivedToAdmin) { ltrDefaultAddEdit.Text = m_refMsg.GetMessage("Default label"); tr_default.Visible = true; if (subscriptionmessage_data.DefaultMessage == 1) { chkDefaultAddEdit.Checked = true; chkDefaultAddEdit.Enabled = false; } else { chkDefaultAddEdit.Checked = false; chkDefaultAddEdit.Enabled = true; } } else { tr_default.Visible = false; } //only friendInvite, SiteInvite supports subject right now. if (!ShowSubject(subscriptionmessage_data.Type)) { rowSubject.Style.Add("display", "none"); } EditSubscriptionToolBar(); }