I'm using the IMAP C++ component to download emails from an Inbox, I can list the attached file, but when I
call SaveAttachedFile, I get:
ChilkatLog: GetMailAttachFilename: DllDate: Aug 24 2012 UnlockPrefix: MWFCOMIMAPMAILQ Username: CBE43009TBNC4J:dempseya Architecture: Little Endian; 32-bit Language: Visual C++ 8.0 VerboseLogging: 1 ckx-imap-attach-nm-1 header is not present --GetMailAttachFilename --ChilkatLog
I confirmed that get_AutoDownloadAttachments was True and I'm using FetchBundle not FetchHeaders, which is
confirmed because I can access the Message Body.
Here are the headers:
Received: from CBDCEX02.CANBURG.LOCAL ([::1]) by CBDCEX02.CANBURG.LOCAL ([::1]) with mapi id 14.01.0323.003; Wed, 24 Oct 2012 13:11:33 +0100 From: xxxxx <firstname.lastname@example.org> To: xxxxx <email@example.com> Subject:  Mrs Mrs Jain Thread-Topic:  Mrs Mrs Jain Thread-Index: Ac2x4MBfk4/5MJb3Q9mwU58vPL+0jQ== Date: Wed, 24 Oct 2012 13:11:33 +0100 Message-ID: <99BE4E0EEF9E1C4D9CEB83881673C6741BD90F@CBDCEX02.CANBURG.LOCAL> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Exchange-Organization-AuthAs: Internal X-MS-Exchange-Organization-AuthMechanism: 04 X-MS-Exchange-Organization-AuthSource: CBDCEX02.CANBURG.LOCAL X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [192.168.1.57] Content-Type: multipart/mixed; boundary=_002_99BE4E0EEF9E1C4D9CEB83881673C6741BD90FCBDCEX02CANBURGLO_ MIME-Version: 1.0 X-AntiVirus: checked (incoming) by Avira MailGuard (Version: 18.104.22.168; AVE:22.214.171.124; VDF:126.96.36.199 ckx-imap-internaldate: 24-Oct-2012 13:11:33 +0100 ckx-imap-uid: 7 ckx-imap-isUid: YES ckx-imap-seen: YES ckx-imap-answered: NO ckx-imap-deleted: NO ckx-imap-flagged: NO ckx-imap-draft: NO ckx-imap-flags: \Seen
What am I doing wrong?
The information in the LastErrorText is poor, and I'm improving it as we speak.
The method will first check the email header for the presence of the ckx-imap-attach-nm-1 header. This would exist if the email was downloaded without attachments (or if it was download via some other means, such as from a POP3 server, or if it was loaded from a .eml file, etc.)
In any case, the "ckx-imap-attach-nm-1 header is not present" message is only informational, because after the header is not found, the method delves into the email object itself to see if the attachment is actually present, and if so, will return the attachment's filename.
It's probable in this case that the email doesn't actually have an attachment. See this Chilkat blog post for information about what is or isn't an attachment:
I found all to be working fine. Here's the latest pre-release with the better logging:
This is the LastErrorText indicating success:
ChilkatLog: GetMailAttachFilename: DllDate: Oct 18 2012 UnlockPrefix: UNTTSTIMAPMAILQ Username: CK2007:Chilkat Architecture: Little Endian; 32-bit Language: Visual C++ 8.0 VerboseLogging: 0 Header field does not exist fieldName: ckx-imap-attach-nm-1 ckx-imap-attach-nm-1 header is not present or empty index: 0 filename: DJ.tab Success. --GetMailAttachFilename --ChilkatLog
The method first checks for the header, does not find it (which is OK), and then examines the email contents, finds the attachment and returns the filename.
Ah yea sorry, wasn't concentrating!
Turns out to be a permissions error as I was trying to save the attachment in Program Files (even though I'm an admin and can manually save files there no problem?) but now that I know that I can save elsewhere.
If I had looked at the correct LastErrorTetxt earlier I wouldn't of wasted your time, although the header missing error in the GetMailAttachFilename error put me off and made me think was an error within Chilkat library, sorry about that.
SaveAttachedFile: DllDate: Oct 19 2012 UnlockPrefix: MWFCOMMAILQ Username: CBE43009TBNC4J:dempseya Architecture: Little Endian; 32-bit Language: Visual C++ 8.0 VerboseLogging: 1 index: 0 dir: C:\Program Files\FileMaker\FileMaker Pro 11 Advanced\ filenameUtf8: DJ.tab OverwriteExisting: 1 combinedFilenameUtf8: C:\Program Files\FileMaker\FileMaker Pro 11 Advanced\DJ.tab openForWriteWin32: Failed to open file (2) localFilePath: C:\Program Files\FileMaker\FileMaker Pro 11 Advanced\DJ.tab currentWorkingDirectory: C:\Users\dempseya\Desktop\DJs From Email osErrorInfo: Access is denied. localWindowsFilePath: C:\Program Files\FileMaker\FileMaker Pro 11 Advanced\DJ.tab --openForWriteWin32 filename: C:\Program Files\FileMaker\FileMaker Pro 11 Advanced\DJ.tab Failed to write complete file (7) Failed to write file Failed. --SaveAttachedFile --ChilkatLog