 |
|
 |
Thanks for the great work, I hope It really helped me!
|
|
|
|
 |
|
 |
Thanks for the great work, It really helped me!
|
|
|
|
 |
|
 |
Hello, sorry for the english but I am Italian.
I have an EML file saved on the disk. This file is signed and have an attachment and a subject. The body of this file is empty.
How can send eml file in vb net?
If possibile, can i send eml file directly whitout use emlReader?
Thanks
|
|
|
|
 |
|
 |
Look for a way to drag and drop from outlook express then use your code to read .eml
any solid working solutions. the net is filled with ideas on this topic but no working examples - c# please
|
|
|
|
 |
|
 |
Relatively simple (I do this, I just can't remember the details). I beleive you start with the drag and drop code from Dave Ewens article (I mention his stuff in the reply below on "How about .msg"). The article is "Reading an Outlook MSG File in C#".
|
|
|
|
 |
|
 |
Maybe a great class but a bad article (no source shown).
|
|
|
|
 |
|
 |
Sorry, I guess I just thought it was too simple to need much code. There is the download for it however.
|
|
|
|
 |
|
 |
Do you know how to create an EML file?
I just want to open an Email with an attachment in. But I don't want my main thread to be stop. I'm using MAPI32.DLL functions to open an Outlook New Email with attachment, but when I do this, the main thread of my app is stopped.
Do you have any idea.
Regards,
Nicolas Hébert
|
|
|
|
 |
|
 |
I don't recall as it's been a while since I've looked at this code. I'm not sure how easy it would be to write an EML file with or without an attachment.
|
|
|
|
 |
|
 |
Just create a mail in outlook and save as...
|
|
|
|
 |
|
 |
If you are using System.Net.Mail.SmtpClient to send your emails, you can use the property DeliveryMethod and set the PickupDirectoryLocation to a location on your hard drive (that is not being pulled from by another SMTP server).
When you then do a send(emai) it will create a .eml file.
www.LongwellTech.com
|
|
|
|
 |
|
 |
Thanks for sharing this code! Looks like it's exactly what I was looking for. One thing I have noticed in the 2 mins I've browsed the code is that you don't close/dispose of the stream passed to the constructor.
Thanks again for saving me lots of time!
|
|
|
|
 |
|
 |
How to extract attchment name, attchment file and detail
I have refer your code it is good but there is not encoding32 for attchment.
Can you paste me code please.
|
|
|
|
 |
|
 |
It was a quick and dirty article. It does what I needed and I never would receive email with attachments so I didn't bother to handle it. You have all the code that I have so you're on your own.
I have found other errors in the code over time but I've made no changes as far as attachements are concerned.
Anyone that want to make changes, post the change here and I will add it to the downloads.
|
|
|
|
 |
|
 |
As Bill mentioned, it is just code that worked fine for him and relies on the expectation that the mail has a simple body or two alternative bodies. Usually each part of a mail has also it's own mime-type, encoding etc. and can as well be nested. The alternative part to a text/plain part for example can also be a multipart/related part that contains several further parts. These parts can be inline disposition or attachment disposition etc. It's also possible that a part is text/rfc822, then we have a mail within a mail. Usually a rfc822 mail (eml) should contain a tree of parts that represent the occurance within the mail after parsing. Each part (as mentioned before) has it's own headers too.
cheers
Peter Brightman
|
|
|
|
 |
|
 |
Hi Peter,
I'd like to try tackle the attachments issue. did you manage to solve it?
Where would be the best place to look
|
|
|
|
 |
|
 |
I just want to add that if you or Peter do have a solution, if you don't care to post it yourself, please send it to jamieson@pocketinet.com and I will update this article.
|
|
|
|
 |
|
 |
I would also want to point this......if there is any solution for this.
Regards, BroxCJ
|
|
|
|
 |
|
 |
Do you have any insight on a message of "An item with the same key has already been added"? I continue to get this using the EML Class in this article. The file is a .eml that has been responed to several times. I believe it has duplicated headers and that may be where the issue is coming in but I cannot pin it down.
|
|
|
|
 |
|
 |
Of course that seems like a problem with a Dictionary objects. As I look at the code, it appears to be the _listUnsupported Dictionary is the only one so it must be that.
I would say i tis trying to add an unsupported header that has already been added. You could just modify the code to do a Contains to see ahead of time if it exists before adding it. That should do it.
|
|
|
|
 |
|
 |
Replace
_listUnsupported.Add(saHdr[0], saHdr[1]);
with
_listUnsupported[saHdr[0]] = saHdr[1];
at line 315 of MsgReader.cs
|
|
|
|
 |
|
 |
Well, headers with a certain name (Receiver for example) can really occur more than one time, so the duplicate key exception will be thrown of course. However because of this, it's better to check if a key exists already and if so, add the value to a list of strings that is used as the value object for the header dictionary rather than a single string. Here's some code that parses a rfc822 message and obtains the headers:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
namespace Tsunamy.Classes
{
class MimeScan
{
private Dictionary<string,>> mailHeaderFields = null;
public MimeScan()
{
mailHeaderFields = new Dictionary<string,>>();
}
public void Scan(String rfc822)
{
List<string> headerFields = new List<string>();
int headerEnd = rfc822.IndexOf(Environment.NewLine + Environment.NewLine);
String mailHeader = rfc822.Substring(0, headerEnd);
char [] crlfs = new char[2];
crlfs[0] = (char)10;
crlfs[1] = (char)13;
String[] headerEntries = mailHeader.Split(crlfs, StringSplitOptions.RemoveEmptyEntries);
String[] headerEntries2 = new String[headerEntries.Length];
foreach (String s in headerEntries)
{
if (s.StartsWith("\t") || s.StartsWith(" "))
{
headerFields[headerFields.Count - 1] += Environment.NewLine + s;
continue;
}
headerFields.Add(s);
}
char[] colon = new char[1];
colon[0] = ':';
foreach (String s in headerFields)
{
String[] headerField = s.Split(colon, 2, StringSplitOptions.RemoveEmptyEntries);
if (mailHeaderFields.ContainsKey(headerField[0]))
{
mailHeaderFields[headerField[0]].Add(headerField[1]);
}
else
{
List<string> fieldText = new List<string>(2);
try
{
fieldText.Add(headerField[1]);
mailHeaderFields.Add(headerField[0], fieldText);
}
catch(Exception e)
{
string msg = e.Message;
Debug.Assert(true);
}
}
}
}
public string GetHeader(string hn)
{
string hdr = string.Empty;
if (mailHeaderFields.ContainsKey(hn))
{
hdr = mailHeaderFields[hn][0];
}
return hdr;
}
}
}
</string></string></string></string>
Peter Brightman
|
|
|
|
 |
|
 |
Awesome! But I also need to read .msg file - you mentioned it took you a week to figure that one out?
Would you be kind to share that one with us too?
Thanks! Great job!
|
|
|
|
 |
|
 |
Why not just read it out of exchange mailboxes, granted getting in is a pain in the **s. Took me a 1200 page book from Amazon( used for $4) to get in, but once in exchange does the hard work...mostly. CDO 1.2 download says it is compatible for 2007 now since it was missing and broke almost every 3rd party app that integrated with exchange.
I had been looking for a way to get at emails, which seems like every linux web app had so I finally just built it. Then, once in exchange, all you have to do is cast every object, trap for non email objects and ignore them and read the object attribs for the mail item.
Then just query the MAPI.Message object.
Not sure what an EML file is, maybe your needs were different.
Just in case you want to see the MAPI login:
try
{
// use of relection for blank params
this.oMapiSession = new MAPI.Session();
this.oMapiSession.Logon(Missing.Value, Missing.Value, false, true, -1, true,
EXCHANGE_SERVER + "\n" + MAIL_USER);
}
catch (Exception ex)
{
throw new ApplicationException("Could not Log in to Email Server", ex);
}
(book was programming outlook and exchange 2003 from MS)
|
|
|
|
 |
|
 |
That's fine for most applications but I was actually using the to read EML files that were not part of Exchange (actually, I thought the exported message files from Outlook were MSG files). They were SMTP messages sent to a server that I was processing.
I used to do a CDO thing with them also at one time because you can still do a MAPI login to get to them but I had problems with the dropped EML file not being completely finished writing while I was accessing it... I could have fixed it but I thought an EML reader was more straight forward that a dependecy on CDO.
|
|
|
|
 |