-
-
Save islaytitans/397a6601014a6f3deabe to your computer and use it in GitHub Desktop.
SendAttachmentEmail Custom Save Actiom WFFM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ISlayTitans.Cms.WebForms.SaveActions | |
{ | |
public class SendAttachmentEmail : SendMessage | |
{ | |
protected override void ExecuteMail(ID formId, AdaptedResultList fields) | |
{ | |
try | |
{ | |
ProcessMessageArgs processMessageArgs = new ProcessMessageArgs(formId, fields, this.MessageType); | |
processMessageArgs.To.Append(this.To.Replace(";", ",")); | |
processMessageArgs.From = this.From.Replace(";", ","); | |
processMessageArgs.IncludeAttachment = this.IsIncludeAttachments; | |
processMessageArgs.Mail.Append(this.Mail); | |
processMessageArgs.Subject.Append(this.Subject); | |
processMessageArgs.Recipient = this.Recipient; | |
processMessageArgs.RecipientGateway = this.RecipientGateway; | |
processMessageArgs.Host = this.Host; | |
processMessageArgs.Port = this.Port; | |
processMessageArgs.IsBodyHtml = this.IsBodyHtml; | |
processMessageArgs.EnableSsl = this.EnableSsl; | |
processMessageArgs.Data.Add("FromPhone", this.FromPhone ?? string.Empty); | |
string[] strArray1; | |
if (!string.IsNullOrEmpty(this.Login)) | |
strArray1 = this.Login.Split('\\'); | |
else | |
strArray1 = new string[1] | |
{ | |
string.Empty | |
}; | |
string[] strArray2 = strArray1; | |
if (strArray2.Length > 0 && !string.IsNullOrEmpty(strArray2[0])) | |
processMessageArgs.Credentials = strArray2.Length != 2 || string.IsNullOrEmpty(strArray2[1]) ? (ICredentialsByHost)new NetworkCredential(strArray2[0], this.Password) : (ICredentialsByHost)new NetworkCredential(strArray2[1], this.Password, strArray2[0]); | |
if (!string.IsNullOrEmpty(this.CC)) | |
processMessageArgs.CC.Append(this.CC.Replace(";", ",")); | |
if (!string.IsNullOrEmpty(this.BCC)) | |
processMessageArgs.BCC.Append(this.BCC.Replace(";", ",")); | |
List<Attachment> attachments = RetrieveAttachments(formId, fields); | |
processMessageArgs.Attachments.AddRange(attachments); | |
CorePipeline.Run("processMessage", (PipelineArgs)processMessageArgs); | |
} | |
catch (Exception ex) | |
{ | |
Log.Error("Failed to send email with attachment in SendAttachmentEmail WFFM save action", ex, this); | |
throw ex; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment