Author Topic: Email.SaveAttachedFile(index) results in emtpy file being created  (Read 4299 times)


  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Getting an email attachment is failing without an error. The file is created succesfully but is 0kb in size. All other aspects are working fine.

Below is the code I've got, as mentioned above, everything in the AttchmentModel() is returned with correct values, including the FileSize, but the call to SaveAttachedFile(index, path) is not populating. Opening the email in Outlook shows the attachment which can then be opened correctly so it's fine in the email side of things.

The code is running on .NetFramework 4.7.1 and uses Chilkat x64 V9.5.0.72

Code: [Select]
                            // Loop over every attachment and process where possible
                            for(int i=0; i<email.NumAttachments; i++)
                                AttachmentModel attachment = new AttachmentModel()
                                    FileName = email.GetAttachmentFilename(i),
                                    ContentType = email.GetAttachmentContentType(i),
                                    FileSize = email.GetAttachmentSize(i),
                                    EmailID = e.EmailID,
                                    AttachmentIndex = i                                   

                                // Save the Attachment to do stuff
                                if(!email.SaveAttachedFile(i, Path.GetTempPath()))
                                    string errorr = email.LastErrorText; // No error is created, the file exists but size is 0kb

                               // ... More code ...

Image showing created file:

Is anyone able to help me with this, I'm hoping it is just something I've missed?