public IAttachmentConstructor GetAttachmentConstructor(HeaderCollection headers) { AttachmentFormat format = headers.GetAttachmentFormat(); bool requiredBody = false; Stream stream = null; if (format == AttachmentFormat.Html) { requiredBody = true; stream = new MemoryStream(); } else if (format == AttachmentFormat.PlainText) { requiredBody = true; stream = new MemoryStream(); } Attachment att = new Attachment( headers, stream, new DecoderSelector(), requiredBody, (err, comm) => ErrorHandler(err, comm)); return(att); }
public static bool IsGraphicFormat(AttachmentFormat af) { return (af == AttachmentFormat.Bmp || af == AttachmentFormat.Jpg || af == AttachmentFormat.Png || af == AttachmentFormat.PngScreenshot); }
public static bool IsGraphicFormat(AttachmentFormat af) { return af == AttachmentFormat.Bmp || af == AttachmentFormat.Jpg || af == AttachmentFormat.Png || af == AttachmentFormat.PngScreenshot; }
private static bool SendEmail(string to, string @from, AttachmentFormat format) { switch (format) { case AttachmentFormat.pdf: // logic break; case AttachmentFormat.xlsx: // logic break; } }
private static Attachment AttachAsBlob(string filter, AttachmentFormat format, bool autoInferenceOfFormat, ArgPoint Point) { var openFileDialog1 = new OpenFileDialog { Filter = filter, RestoreDirectory = true }; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string attachmentName = Path.GetFileName(openFileDialog1.FileName); var a = new Attachment { Name = attachmentName, Title = attachmentName, Link = openFileDialog1.FileName }; if (autoInferenceOfFormat) { format = GetImgFmt(openFileDialog1.FileName); } switch (format) { case AttachmentFormat.Pdf: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); a.Thumb = TryCreatePdfThumb(openFileDialog1.FileName); break; case AttachmentFormat.Jpg: a.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.Png: a.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.Bmp: a.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.ExcelDocSet: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.WordDocSet: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.PowerPointDocSet: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); break; } a.Format = (int)format; a.Name = attachmentName; if (Point != null) { Point.Attachment.Add(a); } return(a); } return(null); }
private static Attachment AttachAsBlob(string filter, AttachmentFormat format, bool autoInferenceOfFormat, ArgPoint Point) { var openFileDialog1 = new OpenFileDialog {Filter = filter, RestoreDirectory = true}; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string attachmentName = Path.GetFileName(openFileDialog1.FileName); var a = new Attachment {Name = attachmentName, Title = attachmentName, Link = openFileDialog1.FileName}; if (autoInferenceOfFormat) format = GetImgFmt(openFileDialog1.FileName); switch (format) { case AttachmentFormat.Pdf: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); a.Thumb = TryCreatePdfThumb(openFileDialog1.FileName); break; case AttachmentFormat.Jpg: a.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.Png: a.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.Bmp: a.MediaData = DaoUtils.CreateMediaData(ImgFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.ExcelDocSet: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.WordDocSet: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); break; case AttachmentFormat.PowerPointDocSet: a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(openFileDialog1.FileName)); break; } a.Format = (int) format; a.Name = attachmentName; if (Point != null) Point.Attachment.Add(a); return a; } return null; }