Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I am looking for a way to create a "ready to send" email-file per c#.

So far I can create .oft files or even .msg files, with this behaviour per Outlook UI.

Is there any way to create such a file per C#?


Thanks in advance

Marc.

What I have tried:

I can create .eml files easily per c# but eml. files are always finished emails (without a send button).
Posted
Updated 16-Mar-16 1:37am
Comments
AnvilRanger 14-Mar-16 13:22pm    
What do you mean by "ready to send"? It sounds like you want to create some file that requires a user to open in Outlook and then send? Why? Why not just send email directly from your application?
Member 7833501 14-Mar-16 13:31pm    
Because the user has to check/edit the email first, then send from his account and then store as sent in outlook.
ZurdoDev 14-Mar-16 14:58pm    
Store it however you want. Then load it in a textbox when the user needs to see it. This is how most email clients work.

I found now a solution!
Perhaps someone else can also use it.

I create now a eml-File and to make it "sendable" / "ready to send" you just have the add the header "X-Unsent: 1" and if you open it now you can immediate send the email :-)

here a short example:

C#
var message = new MailMessage();
.
.
.
message.Headers.Add("X-Unsent", "1");

var client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = @"C:\temp\somedirectory";
client.Send(message);



I hope this will help someone else, it was really hard to find^^
 
Share this answer
 
There actually is no such things as a "Ready-to-send-email." When you are viewing your emails in Outlook they are not oft or eml files or even msg files. Outlook is loading the subject into a subject field and the body into a textbox and pulling the data from its database.

You can do the same thing. Store the email in whatever format you want and then you can display it however you want.
 
Share this answer
 
Comments
Member 7833501 15-Mar-16 4:31am    
Yeah I know, but I need to use Outlook, couse there are also other benefits. A .oft email template does exactly what I want but I need it created by our program. Is there really no way to create that (or something similar) with C#?
ZurdoDev 15-Mar-16 6:28am    
If you only need to support Outlook then use the Microsoft Interop dll for Outlook and then you can create an Outlook email.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900