Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a scenario where i have to create an email using C#. Attach an excel file and then instead of sending it, give a chance to user to view it and then send it manually.
Same kind of functionality is available in VBA where if used .send it sends mail, and if used .Display it pops up the mail to users to see.
Let me know if this is possible in C#.

Thanks,
Sajid
Posted
Comments
Richard MacCutchan 2-Jan-14 7:40am    
Of course it is possible. you just need to provide the controls (and coding) that allow the user to view the message, and then decide whether or not to send it.
db7uk 2-Jan-14 7:40am    
Are you using VSTO or EWS etc? Or is this going to be custom mail client?
sajid hassan 3-Jan-14 2:28am    
i was planning to do this in plain C#. No VSTO
ZurdoDev 2-Jan-14 8:10am    
It's certainly possible by writing a lot of code; however, if VBA supported it you may want to narrow your search down to a .Net equivalent.
Sergey Alexandrovich Kryukov 2-Jan-14 12:53pm    
It is possible but not so easy if you do it from scratch as you would need to support all content (MIME) types which may be used inside the message.
Also, it all depends on your application type. What is it?
—SA

1 solution

Hi Sajid,

You can really do it and it's that simple, use the codes below:

-------------------------------------------------------------
Microsoft.Office.Interop.Outlook.Application app = new  
                          Microsoft.Office.Interop.Outlook.Application();
            MailItem item = app.CreateItem((OlItemType.olMailItem));
            item.BodyFormat = OlBodyFormat.olFormatHTML;
            item.To = "a@test.com;b@test.com;c@test.com";
            item.BCC = "cc@test.com";
            item.Body = "Hello There!";
            item.Display();

-------------------------------------------------------------

Happy Coding :)
Cheers!!
 
Share this answer
 

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