-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Image in the body of the message #139
Comments
Just generate the HTML content and set the appropriate content type, something like this:
Let me know whether this helps or you need more concrete example. |
Hi @karastojko sorry for my lack of details. I'm trying to place an embedded image in a HTML message. I saw examples in other languages using CID in the image src: I was able to create and send the message in HTML following the examples, but how do I create the MIME and put the image and CID in it? Thanks in advance |
There is no Content ID in the header. Since it is of the same format as the Message ID, I believe I can easily add it. Let me try to play with HTML messages and I'l let you know about the results. In the meantime, can you confirm that you have tried to set the Content Disposition header and it did not work? |
I hadn't tried with the Content Disposition header before. So I just tried it and the result was:
I didn't understand what the relationship between the attached file Setting the Content Disposition header didn't work completely |
Can you please provider me a minimal example of this problem so I could try to reproduce it? Regarding the Content-ID, let me play a little bit with the Content-ID header and the HTML content to see the results. |
Here is the example code:
|
So, you would like to create the HTML content together with an image. You have correctly set the image as a MIME part. Since you are dealing with the MIME parts, that means that the HTML also has to be a MIME part:
Additionally, the message itself has to be aware of the multipart structure, so you have to do:
So, the overall code should look like
Let me know if this solves the problem of the email format. Maybe I should set automatically the boundary for the message and thus spare the effort for a programmer to do it. I will add an examples for the multipart messages, it is not obvious how it can be done with mailio. Regarding the Content-ID, I am adding the support for it, I'll post a message when it's done. |
The |
Yes it solved the format problem. |
Now it works perfectly, Thank you! |
Please, could anyone provide me an example of how to place an image in the body of an HTML message ?
The text was updated successfully, but these errors were encountered: