private string AddAttachment(Request request, IEmailAttachment attachment) { string contentType = MimeAttachmentsProxy.GetContentType(attachment); string attachmentName = attachment.DisplayName; // 14781 - CR: 00180301 Professional 7.00 FP3 - Rodyk - Illegal Characters in Path error sending MSG attachments var invalidFileNameCharacters = Path.GetInvalidFileNameChars(); if (attachmentName.IndexOfAny(invalidFileNameCharacters) == -1) { // Hack alert. TFS6626 - customer with 'Lawsoft' which creates dodgy .msg files that have the DisplayName field of the attachment set wrongly // the DisplayName is missing the '.' separating the name and the extension. We work around this for now if (string.IsNullOrEmpty(Path.GetExtension(attachmentName)) && !string.IsNullOrEmpty(Path.GetExtension(attachment.FileName))) { // do we have a display name with no extension and a file name with an extension // there must be a '.' in the filename, since it has an extension. // now test to see if we remove the '.' separating the extension, does the filename end with the attachment name if (attachment.FileName.Remove(attachment.FileName.LastIndexOf('.'), 1).EndsWith(attachmentName)) { // yep, so we have FileName = 'c:\blah\blah\test.docx' and display name = 'testdocx' // which isn't good - as we check for profiles to display based on the extension (which would be blank) // and we re-instate only the displayname of the attachment, not the file name // so we will get the corrected display name from the filename attachmentName = Path.GetFileName(attachment.FileName); } } } string contentId = attachment.ContentId; string index = attachment.ContentItemIndex.ToString(CultureInfo.InvariantCulture); if (string.IsNullOrEmpty(contentId)) contentId = Guid.NewGuid().ToString(); IFile file = new File(attachment.FileName, attachmentName); Attachment requestAttachment = new Attachment(file, contentType, contentId, index, false); requestAttachment.IsSignature = attachment.IsSignature; if (attachment.IsSignature) { requestAttachment.IgnoreForWorkshareActions = true; } CustomProperty prop = new CustomProperty(PropertyNames.LocalFileName, attachment.FileName); if (attachment.RecordKey != null) { string recordkey = attachment.RecordKey; CustomProperty prop2 = new CustomProperty(PropertyNames.RecordKey, recordkey); requestAttachment.Properties = new CustomProperty[] { prop, prop2 }; } else { requestAttachment.Properties = new CustomProperty[] { prop }; } List<Attachment> attachments = new List<Attachment>(request.Attachments); attachments.Add(requestAttachment); request.Attachments = attachments.ToArray(); return attachmentName; }
public void TestCopyTo() { NotesAttachmentsProxy proxy = new NotesAttachmentsProxy(null); IEmailAttachment[] array = new IEmailAttachment[10]; proxy.CopyTo(array, 10); }
private string AddAttachment(IUniversalRequestObject uro, IEmailAttachment attachment) { RequestAttachment requestAttachment = new RequestAttachment(); string attachmentName = attachment.DisplayName; requestAttachment.ContentType = MimeAttachmentsProxy.GetContentType(attachment); requestAttachment.ContentId = attachment.ContentId; requestAttachment.ContentItemIndex = attachment.ContentItemIndex; requestAttachment.Name = attachmentName; requestAttachment.FileName = attachment.FileName; requestAttachment.File = new Workshare.FCS.Lite.Interface.File(attachment.FileName, attachment.DisplayName); requestAttachment.IsSignature = attachment.IsSignature; uro.Attachments.Add(requestAttachment); return attachmentName; }
public void Send(IEmailAttachment email) { SmtpSend(email.To, email.Message, "", email.Attachments); }
public bool Remove(IEmailAttachment item) { throw new NotImplementedException(); }
public void CopyTo(IEmailAttachment[] array, int arrayIndex) { throw new NotImplementedException(); }
public bool Contains(IEmailAttachment item) { throw new NotImplementedException(); }
public void Add(IEmailAttachment item) { throw new NotImplementedException(); }