public Mail(string mailReceiver, string subject, string message, MailEncoding encoding = MailEncoding.MAILTO) { this.mailReceiver = mailReceiver; this.subject = subject; this.message = message; this.encoding = encoding; }
private MailMessage MailMessageFrom(Message message) { MailMessage mailMessage = new MailMessage(); mailMessage.From = message.From; mailMessage.To = message.To; mailMessage.Cc = message.Cc; mailMessage.Bcc = message.Bcc; mailMessage.Subject = message.Subject; mailMessage.Body = message.Body; mailMessage.BodyEncoding = message.Encoding; mailMessage.BodyFormat = (MailFormat)Enum.Parse(typeof(MailFormat), message.Format.ToString()); mailMessage.Priority = (MailPriority)Enum.Parse(typeof(MailPriority), message.Priority.ToString()); foreach (DictionaryEntry entry in message.Headers) { mailMessage.Headers.Add(entry.Key, entry.Value); } foreach (DictionaryEntry entry in message.Fields) { mailMessage.Fields.Add(entry.Key, entry.Value); } foreach (MessageAttachment attachment in message.Attachments) { MailEncoding enc = (MailEncoding)Enum.Parse(typeof(MailEncoding), attachment.Encoding.ToString()); MailAttachment mailAttach = new MailAttachment(attachment.FileName, enc); mailMessage.Attachments.Add(mailAttach); } return(mailMessage); }
public MailAttachment (string filename, MailEncoding encoding) { this.filename = filename; this.encoding = encoding; try { System.IO.File.OpenRead (filename).Close (); } catch (Exception) { throw new System.Web.HttpException ("Cannot find file: '" + filename + "'." ); } }
public MailAttachment (string filename, MailEncoding encoding) { if (SecurityManager.SecurityEnabled) { new FileIOPermission (FileIOPermissionAccess.Read, filename).Demand (); } if (!File.Exists (filename)) { string msg = Locale.GetText ("Cannot find file: '{0}'."); throw new HttpException (String.Format (msg, filename)); } this.filename = filename; this.encoding = encoding; }
public MailAttachment(string filename, MailEncoding encoding) { if (SecurityManager.SecurityEnabled) { new FileIOPermission(FileIOPermissionAccess.Read, filename).Demand(); } if (!File.Exists(filename)) { string msg = Locale.GetText("Cannot find file: '{0}'."); throw new HttpException(String.Format(msg, filename)); } this.filename = filename; this.encoding = encoding; }
public static string Parse(string strForParsing, string checkEncodedStr, string patternEncoding, string patternWithOutEncoding, string strGroupNameToDecode, string strCharset = "charset", string strEncoding = "encoding") { bool isEncoded = strForParsing.Contains(checkEncodedStr); string changedPattern = isEncoded ? patternEncoding : patternWithOutEncoding; Regex regex = new Regex(changedPattern); Match match; if (isEncoded) { match = regex.Match(strForParsing); string encoding = match.Groups[strEncoding].Value; string charset = match.Groups[strCharset].Value; string groupName = match.Groups[strGroupNameToDecode].Value; Regex regexEnc = new Regex(MailMessageRegExPattern.EncodedString); MatchCollection matchCollection = regexEnc.Matches(groupName); string encodedData = string.Empty; IMailEncoder mailEncoder = MailEncoding.GetMailEncoder(encoding); string decodedString = string.Empty; foreach (Match m in matchCollection) { encodedData += m.Groups["data"]; if (encodedData.EndsWith("=")) { string decodedPart = mailEncoder.Decode(encodedData, charset); decodedString += decodedPart; encodedData = string.Empty; } } if (!string.IsNullOrEmpty(encodedData)) { decodedString += mailEncoder.Decode(encodedData, charset); } return(decodedString); } match = regex.Match(strForParsing); return(match.Groups[strGroupNameToDecode].Value); }
public static string Parse(Match match, bool isEncoded, string strGroupNameToDecode, string strCharset = "charset", string strEncoding = "encoding") { string matchedStr = match.Groups[strGroupNameToDecode].Value; if (!isEncoded) { return(matchedStr); } string encoding = match.Groups[strEncoding].Value; string charset = match.Groups[strCharset].Value; Regex regex = new Regex(MailMessageRegExPattern.EncodedString); MatchCollection matchCollection = regex.Matches(matchedStr); string encodedData = string.Empty; IMailEncoder mailEncoder = MailEncoding.GetMailEncoder(encoding); string decodedString = string.Empty; foreach (Match m in matchCollection) { encodedData += m.Groups["data"]; if (encodedData.EndsWith("=")) { string decodedPart = mailEncoder.Decode(encodedData, charset); decodedString += decodedPart; encodedData = string.Empty; } } if (!string.IsNullOrEmpty(encodedData)) { decodedString += mailEncoder.Decode(encodedData, charset); } return(decodedString); }
public MailAttachment(string filename, MailEncoding encoding) {}
public MailAttachment(string filename, MailEncoding encoding) { this._filename = filename; this._encoding = encoding; this.VerifyFile(); }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public MailAttachment(String filename, MailEncoding encoding) { _filename = filename; _encoding = encoding; VerifyFile(); }
/// <include file='doc\SmtpMail.uex' path='docs/doc[@for="MailAttachment.MailAttachment1"]/*' /> public MailAttachment(String filename, MailEncoding encoding) { _filename = filename; _encoding = encoding; }
/// <include file='doc\SmtpMail.uex' path='docs/doc[@for="MailAttachment.MailAttachment"]/*' /> public MailAttachment(String filename) { _filename = filename; _encoding = MailEncoding.UUEncode; }
/// <include file='doc\SmtpMail.uex' path='docs/doc[@for="MailAttachment.MailAttachment"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public MailAttachment(String filename) { _filename = filename; _encoding = MailEncoding.Base64; VerifyFile(); }
public Mail(string mailReceiver, MailEncoding encoding = MailEncoding.MAILTO) { this.mailReceiver = mailReceiver; this.subject = this.message = string.Empty; this.encoding = encoding; }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public MailAttachment(String filename) { _filename = filename; _encoding = MailEncoding.Base64; VerifyFile(); }
public MailAttachment(string filename) { this._filename = filename; this._encoding = MailEncoding.Base64; this.VerifyFile(); }
public MailAttachment(string filename, MailEncoding encoding) { }