Archived Forum Post

Index of archived forum posts

Question:

Retrieve Attachments after Email2.LoadXMLString

Jul 02 '12 at 07:49

Hi,

After Email2.LoadXMLString (mime_msg) I can retrieve all headerdata (from, to, cc, #attachm, ...) but I can't retrieve the attachment filenames.

Email2.GetAttachmentFileName (index) returns 0, also Email2.GetAttachmentSize returns -1, meaning that there is no attachment at that index.

But when I do Email2.SaveAllAttachments ('c:') the attachments are saves.

Can someone tell me what I'm doing wrong please ? Thx in advance.


Answer

What is the XML that you are passing to LoadXMLString?

(To post XML here, replace all "&" chars with "<" and encapsulate in "<pre>" ... "</pre>" tags.)


Answer

It's the same xml that I retrieve with Email2.GetXML I'll post the XML tomorrow if still needed.

thx


Answer

Here we go ... I replaced ip's and addresses ...

<mime_message>
<header>
<delivered-to>mail@gmail.com</delivered-to>
<received>by 99.99.99.999 with SMTP id d6csp175855iep; Fri, 1 Jun 2012 04:55:44 -0700 (PDT)</received>
<received>by 99.99.999.999 with SMTP id n55mr1422583eeh.163.1338551744051; Fri, 01 Jun 2012 04:55:44 -0700 (PDT)</received>
<received>from mailrelay012.isp.belgacom.be (mailrelay012.isp.belgacom.be. [999.999.9.999]) by mx.google.com with ESMTP id en3si7726750wib.31.2012.06.01.04.55.42; Fri, 01 Jun 2012 04:55:44 -0700 (PDT)</received>
<received-spf>neutral (google.com: 999.999.9.999 is neither permitted nor denied by best guess record for domain of 'mailaddress') client-ip=999.999.9.999</received-spf>
<authentication-results spf="neutral (google.com: 999.999.9.999 is neither permitted nor denied by best guess record for domain of 'mailaddress') smtp.mail='mailaddress'">mx.google.com</authentication-results>
<received>from 'mailaddress' ([999.999.9.999) by relay.skynet.be with ESMTP; 01 Jun 2012 13:55:42 +0200</received>
<received>from 'mailaddress' ([999.999.9.999]) by 'mailaddress' with Microsoft SMTPSVC(6.0.3790.3959); Fri, 1 Jun 2012 13:55:41 +0200</received>
<x-mimeole>Produced By Microsoft Exchange V6.5</x-mimeole>
<content-class>urn:content-classes:message</content-class>
<mime-version>1.0</mime-version>
<content-type boundary="----_=_NextPart_001_01CD3FED.77A41F14">
multipart/mixed
</content-type>
<subject>Test Preview OUTLOOK</subject>
<date>Fri, 1 Jun 2012 13:55:41 +0200</date>
<message-id>
<lt;3dab5d133421564e955a7470b311334993158f@xxxxxxxxe<gt; <="" message-id="">
<x-ms-has-attach>yes</x-ms-has-attach>
<x-ms-tnef-correlator></x-ms-tnef-correlator>
<thread-topic>Test Preview OUTLOOK</thread-topic>
<thread-index>Ac0/7XeL6meiNXzYTcK0FkEhufoz1w==</thread-index>
<from>
<addr>fromaddress</addr> <name>me</name>
</from> <to>
<addr>toaddress</addr> <name>me</name>
</to> <x-originalarrivaltime>01 Jun 2012 11:55:41.0031 (UTC) FILETIME=[779ED770:01CD3FED]</x-originalarrivaltime> <ckx-imap-internaldate>01-Jun-2012 11:55:44 +0000</ckx-imap-internaldate> <ckx-imap-uid>68</ckx-imap-uid> <ckx-imap-isuid>YES</ckx-imap-isuid> <ckx-imap-seen>YES</ckx-imap-seen> <ckx-imap-answered>NO</ckx-imap-answered> <ckx-imap-deleted>NO</ckx-imap-deleted> <ckx-imap-flagged>NO</ckx-imap-flagged> <ckx-imap-draft>NO</ckx-imap-draft> <ckx-imap-flags>\Seen</ckx-imap-flags> </header> <body> <subpart> <mime_message> <header> <content-type type="multipart/alternative" boundary="----_=_NextPart_002_01CD3FED.77A41F14"> multipart/related </content-type> </header> <body> <subpart> <mime_message> <header> <content-type boundary="----_=_NextPart_003_01CD3FED.77A41F14"> multipart/alternative </content-type> </header> <body> <subpart> <mime_message> <header> <content-type charset="us-ascii"> text/plain </content-type> <content-transfer-encoding>quoted-printable</content-transfer-encoding> <x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid>0A757D7B-7604-46F7-93BD-7A5F40076BC5</x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid> </header> <body> </body> </mime_message></subpart> <subpart> <mime_message> <header> <content-type charset="us-ascii"> text/html </content-type> <content-transfer-encoding>quoted-printable</content-transfer-encoding> <x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid>02730D0C-A878-475D-9245-65C6925BD97F</x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid> </header> <body> <head><meta http-equiv="3D"Content-Type"" content="3D"text/html;" charset="=3Dus-ascii""><meta name="3DGenerator" content="3D"Microsoft" word="" 12="" (filtered="medium)""><style></style></head><body link="3Dblue" vlink="3Dpurple"><= div class=3DWordSection1>

Here is the mailbody ...

<nbsp;<= p="">

Best Regards,

<nbsp;< span="">

</body></html>]]> </body> </mime_message></subpart> </body> </mime_message></subpart> <subpart> <mime_message> <header> <content-type name="image001.gif"> image/gif </content-type> <content-transfer-encoding>base64</content-transfer-encoding> <content-id><lt;image001.gif@01cd3ffe.3b0f8b90<gt;< content-id=""> <content-description>image001.gif</content-description> <content-location>image001.gif</content-location> <x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid>2B4BBA21-86E3-40D6-98BB-3A08844B3F6D</x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid> </header> <body> </body> </mime_message></subpart> </body> </mime_message></subpart> <subpart> <mime_message> <header> <content-type name="Maserati Gransport - 01.jpg"> image/jpeg </content-type> <content-transfer-encoding>base64</content-transfer-encoding> <content-description>Maserati Gransport - 01.jpg</content-description> <content-disposition filename="Maserati Gransport - 01.jpg">attachment</content-disposition> <x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid>110209BA-9E2E-4040-9414-6D00D792C396</x-ec0d2a8e-5cb7-4969-9c36-46d859d137be-partid> </header> <body> </body> </mime_message></subpart> </body> </mime_message>

Answer

ok ... found it. Noob mistake :-s

After having programmed in java and C#, I was developing this in a language where the first element of a loopcounter starts at index 1 instead of 0 :-s

Lessons learned ... attach more than 1 file ...

Sorry for wasting time ...