I am working to receive pop3 emails via OpenPop component. I am receiving emails from the server and saving to the sql database. At this point, there is no problem.
But today, I realized, some images are not showing on the richtextbox. This email's source code :
Original image file name : image001.jpg
Content-Type: image/jpeg; name="image001.jpg"
Content-Transfer-Encoding: base64
Content-ID: [email protected]
And
In html body, cid value : [email protected]
With above code, I am not living any problem. Because I am getting image file name from the CID value. (image001.jpg). I am getting image from the SQL server with the true image file name.
But, if we send the same email via Gmail web-interface;
Content-Type: image/jpeg; name="image001.jpg"
Content-Disposition: inline; filename="image001.jpg"
Content-Transfer-Encoding: base64
Content-ID: ii_iksd5tmd1_152f4c90885b6c5d
And we see on the richtextbox the CID value :
cid:ii_iksd5tmd1_152f4c90885b6c5d
Here is the problem.
CID value is not contains the file name information. So, I am not getting the image. The CID value is changing when the emails receiving from the Gmail.
In order to catch true image file name, what should I do?
Thanks so much.
Use the following logic to get the file name:
If the
Content-Disposition
header exists, use thefilename
parameter value as the attachment file name. Otherwise fall back to using thename
parameter value on theContent-Type
header if that exists.The
Content-Id
header value can be anything, all you can really expect from it is that it is a unique string within the context of the message.Obviously the cid: URL in the HTML of the message refers to the
Content-Id
header value, so if you want to be able to reference the attachment at a later date after saving the attachments to disk, then you'll also need to save theContent-Id
in the database record for the attachment.