private static bool AlternativeViewsAreAvailable(AlternateViewCollection views) { var textTypes = new[] { MediaTypeNames.Text.Plain, MediaTypeNames.Text.Html }; return(views.Any() && (views.Count <= 2) && !views.Select(av => av.ContentType.MediaType).Except(textTypes).Any()); }
public MailMessage() { RawFlags = new string[0]; To = new Collection<MailAddress>(); Cc = new Collection<MailAddress>(); Bcc = new Collection<MailAddress>(); ReplyTo = new Collection<MailAddress>(); Attachments = new Collection<Attachment>(); AlternateViews = new AlternateViewCollection(); }
public MailMessage() { this.To = new MailAddressCollection(); AlternateViews = new AlternateViewCollection(); Attachments = new AttachmentCollection(); Bcc = new MailAddressCollection(); CC = new MailAddressCollection(); ReplyToList = new MailAddressCollection(); Headers = new Dictionary<string, string> {{"MIME-Version", "1.0"}}; }
internal static AlternateViewCollection ConvertEMailBodyAlternateViewArrayToAlternateViewCollection(EMailBodyAlternateView[] Views) { MailMessage mail = new MailMessage(); AlternateViewCollection translatedCol = mail.AlternateViews; foreach (EMailBodyAlternateView view in Views) { translatedCol.Add((AlternateView)view); } return(translatedCol); }
public MailMessage() { this.to = new MailAddressCollection(); alternateViews = new AlternateViewCollection(); attachments = new AttachmentCollection(); bcc = new MailAddressCollection(); cc = new MailAddressCollection(); replyTo = new MailAddressCollection(); headers = new NameValueCollection(); headers.Add("MIME-Version", "1.0"); }
public AlternateViewCollectionTest() { avc = new MailMessage("*****@*****.**", "*****@*****.**").AlternateViews; av = AlternateView.CreateAlternateViewFromString("test", new ContentType("text/plain")); }
private static string GetTheAlternativeView(AlternateViewCollection views, string type) { return(AlternativeViewsAreAvailable(views) ? GetViewContent(views, type) : null); }
private static string GetViewContent(AlternateViewCollection views, string type) { var view = views.FirstOrDefault(v => v.ContentType.MediaType == type); return(view == null ? null : GetViewContent(view)); }
public void GetReady() { avc = new MailMessage("*****@*****.**", "*****@*****.**").AlternateViews; av = AlternateView.CreateAlternateViewFromString("test", new ContentType("text/plain")); }
/// <summary> /// Add alternate view for plain text /// </summary> /// <param name="sender"></param> /// <param name="message"></param> /// <remarks> /// Value is shorter line in code that sends emails /// </remarks> public static void PlainTextView(this AlternateViewCollection sender, string message) { sender.Add(AlternateView.CreateAlternateViewFromString(message, null, "text/plain")); }
/// <summary> /// Add alternate view for html /// </summary> /// <param name="sender"></param> /// <param name="message"></param> /// <remarks> /// Value is shorter line in code that sends emails /// </remarks> public static void HTmlView(this AlternateViewCollection sender, string message) { sender.Add(AlternateView.CreateAlternateViewFromString(message, null, "text/html")); }
/// <summary> /// Initializes an empty instance of the OpaqueMail.MailMessage class. /// </summary> public MailMessage() : base() { AllRecipients = new List<string>(); AlternateViews = new AlternateViewCollection(); Attachments = new AttachmentCollection(); Bcc = new MailAddressCollection(); Body = ""; BodyContentType = ""; BodyDecoded = false; CC = new MailAddressCollection(); CharSet = ""; ContentLanguage = ""; ContentTransferEncoding = ""; ContentType = ""; DeliveredTo = ""; Headers = new NameValueCollection(); Importance = ""; MimeBoundaryName = "OpaqueMail-boundary"; ProcessingFlags = MailMessageProcessingFlags.IncludeRawHeaders | MailMessageProcessingFlags.IncludeRawBody; RawFlags = new HashSet<string>(); ReturnPath = ""; SmimeEncryptedEnvelope = false; SmimeEncryptionOptionFlags = SmimeEncryptionOptionFlags.RequireCertificateVerification; SmimeSettingsMode = SmimeSettingsMode.RequireExactSettings; SmimeSigned = false; SmimeSigningCertificateChain = new X509Certificate2Collection(); SmimeSigningOptionFlags = SmimeSigningOptionFlags.SignTime; SmimeTripleWrapped = false; SubjectIdentifierType = SubjectIdentifierType.IssuerAndSerialNumber; To = new MailAddressCollection(); }