473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Trying to send custom emails with Postal.NET

Sl1ver
196 100+
I am trying to send multiple emails using my own email class but I get an error where it says "element contains the same key!"

So I take it the view for my email gets added everytime but it already exists.I just don't know how to check if it exists or how to readd it.

Expand|Select|Wrap|Line Numbers
  1. var viewsPath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/Emails"));
  2.             var engines = new ViewEngineCollection();
  3.             engines.Add(new FileSystemRazorViewEngine(viewsPath));
  4.  
  5.             //Smtp Cliet
  6.             SmtpSection smtpSection = (SmtpSection)ConfigurationManager.GetSection("mailSettings/" + emailSection.ToString());
  7.  
  8.             var client = new SmtpClient(smtpSection.Network.Host, smtpSection.Network.Port)
  9.             {
  10.                 Credentials = new NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password),
  11.                 EnableSsl = false
  12.             };
  13.  
  14.             var emailService = new Postal.EmailService(engines, () => client);
  15.             email.ViewName = emailType.ToString();
  16.  
  17.             emailService.Send(email);
At the top where I add the viewPath is where the issue is. It always works when I run it for the first time but after that it it complains as it obviously already exists.
Jul 24 '16 #1
0 1435

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brandon | last post by:
I am trying to send a custom e-mail using asp.net but am having trouble. The code that I found to do this is: <% Dim msgMail as New MailMessage msgMail.From = "frombla@blabla.com" msgMail.To =...
1
by: shubhrarustagi | last post by:
hi, I'm a beginner developer and one of my first tasks is to develop automatic emails application in .net. We need to send automatic emails to users whose credit cards are expiring, create email...
0
by: =?Utf-8?B?am9lbA==?= | last post by:
When I posted a comment, I received a message that you had tried 3 times to send me emails but had been unable to do so. You asked me to solve this problem. How do I solve this problem? -- joel
1
by: prasath1984 | last post by:
hi, This is prasath i want the code to send bulk emails
2
by: techsri | last post by:
Hi, We are going to launch a website which offers free e-learning courses to the users. we are facing some problems to build my site. The problem is about, We want add push email feature to our...
2
by: palanisiva | last post by:
Hi, I am using PHP mailer to send out 2 different emails. The problem I am having is only the first email is ever sent out. Below is my code. The first email $to but i add two mail id mail not...
3
digicrowd
by: digicrowd | last post by:
http://bytes.com/images/howtos/applemail_sig_icon.jpg You can make your emails fancy in Mail.app by using Rich Text formatting or even included Stationery. But, a simple way to send your own HTML...
11
by: londres9b | last post by:
I want to send multiple emails from php with one unique script. The emails are from a mysql database table. How can I achieve this?
17
by: john garvey | last post by:
Hi It's been a while since I asked a question and I've trolled many, many discussion groups and forums without success and I'm not sure that my problem has a solution but here goes. I have a...
9
by: bears1990 | last post by:
My goal is to send out a message (with attachments) to individuals within my client table. In a form, I have created fields that will capture the Subject, Body and attachment path. I have modified...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.