PacificaResearch
asked on
MapiSendMail attachments don't display
I'm using MapiSendMail to send email with a .PNG graphic file as an attachment. The email is delivered and received OK, but the .PNG file arrives as an attachment, not as a graphic displayed in the email body as I would like. The Microsoft documentation states that an attached file will simply display by default unless the nPosition member of the MapiFileDesc struct is -1.
The contents of the received email have something like this:
MIME-Version: 1.0
To: donald@pacificaresearch.co m
Subject: Sales Invoice #107628 from Skyline Fluid Power, Inc
Content-Type: multipart/mixed;
boundary="------------0005 0503040802 0502090309 "
This is a multi-part message in MIME format.
--------------000505030408 0205020903 09
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Your sales invoice #107628 from Skyline Fluid Power, Inc is attached.
--------------000505030408 0205020903 09
Content-Type: image/png;
name="email_107628.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="email_107628.png "
iVBORw0KGgoAAAANSUhEUgAACf YAAAzkCAIA AACYgxr+AA AABmJLR0QA /wD/AP+gva eTAAAA
CXBIWXMAAC4jAAAuIwF4pT92AA AgAElEQVR4 nOzd29ajKq IG0LhGvf8r uy/SlZ0yis gZnXP0
Ra/8igjGSvwCLOu6vgAAAAAAAA CYwX+9KwAA AAAAAABALB EvAAAAAAAA wDREvAAAAA AAAADT
EPECAAAAAAAATEPECwAAAAAAAD ANES8AAAAA AADANES8AA AAAAAAANMQ 8QIAAAAAAA BMQ8QL
AAAAAAAAMA0RLwAAAAAAAMA0RL wAAAAAAAAA 0xDxAgAAAA AAAExDxAsA AAAAAAAwDR EvAAAA
The .PNG file is there. I think this is a clue:
Content-Disposition: attachment;
If I open an email dialog and drag the .PNG file into the body, I get something like this:
Content-Type: image/png;
name="email_107628.png"
Content-Transfer-Encoding: base64
Content-ID: <part1.02020306.07010600@p acificares earch.com>
Content-Disposition: inline;
filename="email_107628.png "
iVBORw0KGgoAAAANSUhEUgAACf YAAAzkCAIA AACYgxr+AA AABmJLR0QA /wD/AP+gva eTAAAA
CXBIWXMAAC4jAAAuIwF4pT92AA AgAElEQVR4 nOzd29ajKq IG0LhGvf8r uy/SlZ0yis gZnXP0
where
Content-Disposition: inline;
seems to specify that the .PNG file should be displayed, not attached. How can I get MapiSendFile to put the .PNG file inline and not attached?
The contents of the received email have something like this:
MIME-Version: 1.0
To: donald@pacificaresearch.co
Subject: Sales Invoice #107628 from Skyline Fluid Power, Inc
Content-Type: multipart/mixed;
boundary="------------0005
This is a multi-part message in MIME format.
--------------000505030408
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding:
Your sales invoice #107628 from Skyline Fluid Power, Inc is attached.
--------------000505030408
Content-Type: image/png;
name="email_107628.png"
Content-Transfer-Encoding:
Content-Disposition: attachment;
filename="email_107628.png
iVBORw0KGgoAAAANSUhEUgAACf
CXBIWXMAAC4jAAAuIwF4pT92AA
Ra/8igjGSvwCLOu6vgAAAAAAAA
EPECAAAAAAAATEPECwAAAAAAAD
AAAAAAAAMA0RLwAAAAAAAMA0RL
The .PNG file is there. I think this is a clue:
Content-Disposition: attachment;
If I open an email dialog and drag the .PNG file into the body, I get something like this:
Content-Type: image/png;
name="email_107628.png"
Content-Transfer-Encoding:
Content-ID: <part1.02020306.07010600@p
Content-Disposition: inline;
filename="email_107628.png
iVBORw0KGgoAAAANSUhEUgAACf
CXBIWXMAAC4jAAAuIwF4pT92AA
where
Content-Disposition: inline;
seems to specify that the .PNG file should be displayed, not attached. How can I get MapiSendFile to put the .PNG file inline and not attached?
You .....
http://msdn.microsoft.com/en-us/library/windows/desktop/dd296732(v=vs.85).aspx
If this is the language you use, there is a file description structure where you might be able to identify that a file is inline, while another is an attachment.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd296732(v=vs.85).aspx
If this is the language you use, there is a file description structure where you might be able to identify that a file is inline, while another is an attachment.
ASKER
The language is C++. The structs that you mention are initialized and set up according to Microsoft documentation. MapiSendMail clearly understands the file type:
Content-Type: image/png;
name="email_107628.png"
The documentation for MapiFileDesc.nPosition states:
An integer used to indicate where in the message text to render the attachment. Attachments replace the character found at a certain position in the message text. That is, attachments replace the character in the MapiMessage structure field NoteText[nPosition]. A value of -1 (0xFFFFFFFF) means the attachment position is not indicated; the client application will have to provide a way for the user to access the attachment.
I've tried various values for nPosition, including integers from 0 to 10.
Content-Type: image/png;
name="email_107628.png"
The documentation for MapiFileDesc.nPosition states:
An integer used to indicate where in the message text to render the attachment. Attachments replace the character found at a certain position in the message text. That is, attachments replace the character in the MapiMessage structure field NoteText[nPosition]. A value of -1 (0xFFFFFFFF) means the attachment position is not indicated; the client application will have to provide a way for the user to access the attachment.
I've tried various values for nPosition, including integers from 0 to 10.
I do not believe the issue is with position specification.
You need to alter the Content-Disposition: entry. I am uncertain what adds it. and whether it is defaulted when using mapistrattachment or something similar might be defaulting to attachment, unless a differnet set is selected.
You need to alter the Content-Disposition: entry. I am uncertain what adds it. and whether it is defaulted when using mapistrattachment or something similar might be defaulting to attachment, unless a differnet set is selected.
ASKER
I don't find any documentation on a mapistrattachment() function. Is there such a thing?
I must have confused methods between ...
http://msdn.microsoft.com/en-us/library/windows/desktop/dd296732%28v=vs.85%29.aspx
are you using a list to enumerate the files and then filedesc
http://msdn.microsoft.com/en-us/library/windows/desktop/cc765770.aspx
instead of using a file path, see if you attach a datastream.
If you create a message:
text
attachment,
text
I think the structure listing the type of files should resolve the issue, though I seem to be drawing a blank on the reference .....
http://msdn.microsoft.com/en-us/library/windows/desktop/dd296732%28v=vs.85%29.aspx
are you using a list to enumerate the files and then filedesc
http://msdn.microsoft.com/en-us/library/windows/desktop/cc765770.aspx
instead of using a file path, see if you attach a datastream.
If you create a message:
text
attachment,
text
I think the structure listing the type of files should resolve the issue, though I seem to be drawing a blank on the reference .....
ASKER
I don't understand this reference:
are you using a list to enumerate the files and then filedesc
http://msdn.microsoft.com/en-us/library/windows/desktop/cc765770.aspx
The struct that defines the file type requires some kind of x.400 document type that Microsoft doesn't document in any understandable way. There example is something like "Microsoft Excel Spreadsheet".
MapiSendMail already seems to understand the file type:
Content-Type: image/png;
name="email_107628.png"
are you using a list to enumerate the files and then filedesc
http://msdn.microsoft.com/en-us/library/windows/desktop/cc765770.aspx
The struct that defines the file type requires some kind of x.400 document type that Microsoft doesn't document in any understandable way. There example is something like "Microsoft Excel Spreadsheet".
MapiSendMail already seems to understand the file type:
Content-Type: image/png;
name="email_107628.png"
Agree, the X.400 is an ITU standard.
Though it is unclear how there are examples of someone using outlook API to generate a message using C++/VB and they set a parameter to a value.
As you noted in your original question, the issue is how do you indicate that filea.png is an attachment versus fileb.png is an inline attachment via the control whether the Content-disposition is present and if it is how to control account for the value of inline or attachment.
Note that even if an image is attached and is marked as inline, the recipient still has control on whether images are to be displayed.
Though it is unclear how there are examples of someone using outlook API to generate a message using C++/VB and they set a parameter to a value.
As you noted in your original question, the issue is how do you indicate that filea.png is an attachment versus fileb.png is an inline attachment via the control whether the Content-disposition is present and if it is how to control account for the value of inline or attachment.
Note that even if an image is attached and is marked as inline, the recipient still has control on whether images are to be displayed.
ASKER
So far, no answer to this question:
How do I get MapiSendMail to embed the attached .PNG file, as the Microsoft documentation clearly states it will do, automatically?
The Microsoft documentation is not ambiguous in any way about this. It states that the file will be rendered in the body of the email. That doesn't happen. Can it be made to happen? Does anyone have any experience with this? I receive emails every day with graphics embedded in them. Someone knows how to do this.
How do I get MapiSendMail to embed the attached .PNG file, as the Microsoft documentation clearly states it will do, automatically?
The Microsoft documentation is not ambiguous in any way about this. It states that the file will be rendered in the body of the email. That doesn't happen. Can it be made to happen? Does anyone have any experience with this? I receive emails every day with graphics embedded in them. Someone knows how to do this.
I've seen examples dealing the outlook API.
Unfortunately have not seen an example that fits your need, nor as you pointed out there is a clear example on the type x.400 designated that will solve the issue.
Unfortunately have not seen an example that fits your need, nor as you pointed out there is a clear example on the type x.400 designated that will solve the issue.
The way I've done embedded images is to use a HTML body and at the point I want the image inserted, I add:
<img src="cid:MyImageID1">
Then add the attachment, and set it's content ID to: "MyImageID1".
I also mark the attachment as hidden, and set the mail item to hide the paper clip.
Don't do that in C++ however, so I'm note sure if that helps or not. Might get you pointed in the right direction though.
Jim.
<img src="cid:MyImageID1">
Then add the attachment, and set it's content ID to: "MyImageID1".
I also mark the attachment as hidden, and set the mail item to hide the paper clip.
Don't do that in C++ however, so I'm note sure if that helps or not. Might get you pointed in the right direction though.
Jim.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No expert was able to provide any solution or assistance. This may be because no expert has tried to use the MapiSendMail function, or Microsoft has not fixed bugs in the function.
I am not sure whether the means by which you code your app includes a method to alter/set the disposition setting in the construct from the defaulting attachment to inline.