Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
Hi,

I have multiple .eml (Outlook Email Format) templates with different messages (like one for success email, one for failure email etc).
Based on some conditions, I need to choose an .eml template, fill in the required data (To, From, Message etc)and send the email.

For Example: If a task is successful, system should choose the .eml template, which contains message for successful task completion, use that .eml template for creating an email and send the email.

Is it possible?

How can I do that?

A code sample will be appreciated.

Regards
Posted
Updated 28-Dec-10 1:55am
v2
Comments
Henry Minute 28-Dec-10 7:56am    
What have you tried so far?
Which part of the problem are you stuck on?
maheshk_blr 28-Dec-10 8:06am    
I only know, How to send automatic emails using 'MailMessage' object, I have no idea of working with .eml templates.

1 solution

monu_1983 wrote:
Is it possible?

Yup :)

monu_1983 wrote:
How can I do that?

  1. Check if you need to send an email
  2. Load the template into a string
  3. Replace the placeholders in the template with actual values (rename one of those .eml files to a .txt file and open it in notepad - it's a string you can manipulate)
  4. Send the emails (you can put multiple addresses in the bcc and set the "to" to yourself if you want to email a lot of people in one shot, just don't overdo it)


You might want to research a bit more, like;

  • Where are my emailaddresses coming from? The things you put in the To and Fro, where is that stored?
  • Where are the templates stored? How do the placeholders look?
  • What are the conditions on which you trigger the sending? Is it a user-initiated action, or something more complex?
  • Hunt the web for a code-snippet to send emails in your favorite .NET language. Or use the one from the manual[^]

monu_1983 wrote:
A code sample will be appreciated.

For which part of this project? You could Google for MailMerge-examples :)
 
Share this answer
 
Comments
maheshk_blr 30-Dec-10 0:05am    
Thanks for a very nice 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