It is possible (out of the box) to send Mht email now in .NET 2.0
I've taken a look at LinkedResource & AlternateView and I'm able to send out emails. However, there is no documentation on what is going on behind the scenes.
I've sent you an Mht email using what we have. You should be able to see the images without having to "download" image. In other words, outlook will not block these images.
I have the ability to generate the mht content. I'd like to be able to "send" this as an email using the smtp class that comes out of the box.
I'd like to better understand the ContentId property. Is this the same as CID that is used in the MHT content
If this feature is something you beleive you could leverage in your future applications (ie. create an HTML mail by referencing a .mht file), please write to us and let us know why you would like to see such support added to the System.Net.Mail namespace. You can email our team directly at nclasks@microsoft.com.dontspam (remove the .dontspam).
Shiv Kumar, I looked at the issue a little more deeply. I wanted to whip something up this morning but seems like it is slightly more involved that I originally thought. 1. we need to parse the headers 2. Each content type 3. decode the content type 4. Add it to the MailMessage class.
Basically we will be decoding the content and re encoding the content when we add it to the MailMessage. While this is doable, this seems like a weekend project :-)
for now you might have to stick with the external tools. Very sorry. We will look at this in the next release
So I did some research on this and found that mht is a MIME formatted HTML. The official content type for MHT is message/rfc822. There is lies the issue. The content type is making the email user agent [Outlook/Express] interpret this as a an attachment since it thinks that it can't display the contents inline. SmtpClient client = new SmtpClient("host", 25); client.Timeout = 5000; client.UseDefaultCredentials = true; MailMessage msg = new MailMessage("<from>", "<to>"); msg.AlternateView view = new AlternateView(@"C:\Mht Email (Html Archive) - Microsoft Technical Forums.mht"); view.ContentType = new ContentType("message/rfc822"); msg.AlternateViews.Add(view); client.Send(msg);
What you might really need to do is to parse the MHT file and select individual components. Like you would read the parts yourself and then use the Object model to add the components. Does not sound too exciting to me :-) We don't have (currently) a mime parser that you could use to do this either.
Sorry for the inconvineince. I will do some more research on this and see if there is a way to do this. I will let you know if I find anything.
I sent Mike an email to the address he mentioned that will show you what I mean.
We have our own set of component that do this, but we're also using Chikat. The issue is that we're using the FCL version of the smtp component for everything else but have to resort to using another smtp component (our own or a thrid party) simply to "send" the MHT email.
So even if we got the ability to send mht content as email I'd be happy.
I do believe, you have the stuff there. It's probably a matter or parsing the various content parts.
If I understood the ContentId property better I'll probably have a solution. Not an easy to use one but it can then be abstracted to make it simple to use.
If you look at the MHT that you generated or the one I sent you, you'll see that images and other collateral are cross referenced using a CID (as per the spec).
I don't mnd having to build the MHT myself as long as I can "send" it using the new smtp class.
Tell me exactly what you are trying to send and what the content type is. It should be fairly painless as you can send any content type of your choice. What exactly do you want to know that happens behind the scenes
1. You create an altenate view and set the content type to the content type of your choice 2. Set the content 3. When you send it we send the right content type header 4. We loook at the content and use either base 64 or Quoted pritable transfer encoding.
Let me know if you need to see a sample. I don't know what the MHT is, i will find out
In reality, outlook express and outlook both support mht and in fact do show the content inline. :)
And therein lies my predicament.
However, what you're really saying is that if I were to contruct the "parts" using the avilable object model (which was what my original experiement was) things should work just fine
Towards that end, I have a question related to the ContentId property that LinkedResource and AlternateView have. How and/or why would I use these
On the second thought I think the CDO offers very rich parsing functionality you could use to send mail as well. Using some COM Interop and stuff, you can easily obtain the parts of the message and send it. I will take a look at this sometime this afernoon - in the mean time if you have other ideas let me know
This is what I tried. I'm trying to send html email and Mht (Html Archive) email.
I attached an image and an html file. I'm not sure, how to reference the image in the html. That is, what should the src attribute's value be.
When I send the email, I do see the image as expected and it kind of looks like it's Mht and not html.
In the case of Mht, I can "create" the archive but I don't know how to "attach" it to the email.
You can create an Mht file by simply browsing to a website using I.E. Then choose the File | Save As Option. be sure to choose "Web Archive single file" option.
Now that you have this file, send it in an email such that it doesn't appear as an attachment but rather an html email. Further, outlook shouldn't block images.
Mht Email (Html Archive)
Hok Peng
I've sent you an Mht email using what we have. You should be able to see the images without having to "download" image. In other words, outlook will not block these images.
I have the ability to generate the mht content. I'd like to be able to "send" this as an email using the smtp class that comes out of the box.
I'd like to better understand the ContentId property. Is this the same as CID that is used in the MHT content
Xrider
If this feature is something you beleive you could leverage in your future applications (ie. create an HTML mail by referencing a .mht file), please write to us and let us know why you would like to see such support added to the System.Net.Mail namespace. You can email our team directly at nclasks@microsoft.com.dontspam (remove the .dontspam).
firestorm79
It would be nice if one could load (from file) and assign (from an in memory stream) a .eml formatted file.
This file could in turn be multi-part.
mnimanndasexivan
I looked at the issue a little more deeply. I wanted to whip something up this morning but seems like it is slightly more involved that I originally thought.
1. we need to parse the headers
2. Each content type
3. decode the content type
4. Add it to the MailMessage class.
Basically we will be decoding the content and re encoding the content when
we add it to the MailMessage. While this is doable, this seems like a weekend project :-)
for now you might have to stick with the external tools. Very sorry.
We will look at this in the next release
Salwani
So I did some research on this and found that mht is a MIME formatted HTML.
The official content type for MHT is message/rfc822. There is lies the issue.
The content type is making the email user agent [Outlook/Express] interpret this as a
an attachment since it thinks that it can't display the contents inline.
SmtpClient client = new SmtpClient("host", 25);
client.Timeout = 5000;
client.UseDefaultCredentials = true;
MailMessage msg = new MailMessage("<from>", "<to>");
msg.AlternateView view = new AlternateView(@"C:\Mht Email (Html Archive) - Microsoft Technical Forums.mht");
view.ContentType = new ContentType("message/rfc822");
msg.AlternateViews.Add(view);
client.Send(msg);
What you might really need to do is to parse the MHT file and select individual components. Like you would read the parts yourself and then use the Object model
to add the components. Does not sound too exciting to me :-) We don't have (currently) a mime parser that you could use to do this either.
Sorry for the inconvineince. I will do some more research on this and see if there is a way to do this. I will let you know if I find anything.
Darkness84
FADI Abdel-qader
John R. Durant - MSFT
offers some insight into this...
bhaber
I sent Mike an email to the address he mentioned that will show you what I mean.
We have our own set of component that do this, but we're also using Chikat. The issue is that we're using the FCL version of the smtp component for everything else but have to resort to using another smtp component (our own or a thrid party) simply to "send" the MHT email.
So even if we got the ability to send mht content as email I'd be happy.
I do believe, you have the stuff there. It's probably a matter or parsing the various content parts.
If I understood the ContentId property better I'll probably have a solution. Not an easy to use one but it can then be abstracted to make it simple to use.
If you look at the MHT that you generated or the one I sent you, you'll see that images and other collateral are cross referenced using a CID (as per the spec).
I don't mnd having to build the MHT myself as long as I can "send" it using the new smtp class.
Jagjot Singh
It should be fairly painless as you can send any content type of your choice.
What exactly do you want to know that happens behind the scenes
1. You create an altenate view and set the content type to the content type of your choice
2. Set the content
3. When you send it we send the right content type header
4. We loook at the content and use either base 64 or Quoted pritable transfer encoding.
Let me know if you need to see a sample. I don't know what the MHT is, i will find out
Thiago Santos
And therein lies my predicament.
However, what you're really saying is that if I were to contruct the "parts" using the avilable object model (which was what my original experiement was) things should work just fine
Towards that end, I have a question related to the ContentId property that LinkedResource and AlternateView have. How and/or why would I use these
Merrill Groat
JonOfAllTrades
Thank you for your reply.
This is what I tried. I'm trying to send html email and Mht (Html Archive) email.
I attached an image and an html file.
I'm not sure, how to reference the image in the html. That is, what should the src attribute's value be.
When I send the email, I do see the image as expected and it kind of looks like it's Mht and not html.
In the case of Mht, I can "create" the archive but I don't know how to "attach" it to the email.
You can create an Mht file by simply browsing to a website using I.E. Then choose the File | Save As Option.
be sure to choose "Web Archive single file" option.
Now that you have this file, send it in an email such that it doesn't appear as an attachment but rather an html email. Further, outlook shouldn't block images.
Slamhart
I could not get the mht to be displayed properly in Outlook.
What did you do to get this to work