Effectively I'm trying to send some template emails so that I can test a few components that handle reading from mailboxes.
I could just load up outlook and send a couple of emails but I'm looking to find a solution that can read thousands of emails at a time so I need to bulk send these templates t test the reading code.
When I say bulk send ... I have about 10 to 15 templates (varies) and I want to send about 1,000 copies of each to the given mailbox.
Now here's th sticking point ...
I could just fire up an instance of the SMTP client and declare a new MailMessage
object then send that using the SMTP client ... the problem is that my email templates contain custom header info so its not just a matter of msg.Body = someText
and then setting the To and From and Subject fields.
I don't want to spend time manually parsing these emails because the headers are quite lengthy and contain a lot of custom values that I'll be working on later.
So if I have a txt
or eml
file how do I send that raw text to my mailbox so I can perform my afformentioned testing?
The best way I know to do this is using MailBee.NET objects which are not free, but you can download a trial: http://www.afterlogic.com/mailbee-net/email-components
Then what you are looking for is something like this:
MailBee.Mime.MailMessage message = new MailMessage();
message.LoadMessage(filestream);
MailBee.SmtpMail.Smtp.QuickSend(message);
Disclosure: I don't work for AfterLogic, but some of their tools have been a big help with Elastic Email (http://elasticemail.com)
If you have a well-formed RFC822 message, just transfer it as-is in the DATA phase of the SMTP transaction. On Unix, it's basically just
sendmail -oi -t <file
On some Linux distros, sendmail
is not installed on the PATH; try /usr/lib/sendmail
or consult a forum for your particular distro if you cannot come up with a few informed guesses on your own.
Another one that came up in my search is EASendMail by Email Architect. Like MailBee.NET it's not free but I have found specific documentation that shows of the feature you are asking for by calling the SendRawMail method. That example is in C++/CLI but the same would apply to code written in C# or VB.NET. If I end up using trial to test it out I'll post my feedback here.
来源:https://stackoverflow.com/questions/8973771/how-do-i-send-an-email-when-i-already-have-it-as-a-string