0
votes

I need to create a plugin that will send an email for all people listed in web resource XML file. There will be only email addresses in it, no names etc, just email addresses. I don't want to create new contacts out of them. I also would prefer that the sender would be "anonymous". By saying that I mean that I would not like to create a new System User for that purpose.

So I did find this example http://msdn.microsoft.com/en-us/library/hh210217.aspx and yes it works, but as I said I would not like to use CRM entities as recipients or a sender. And it would be better if the CRM would not create an email activity entity either.

So what I really need is just a simple script that will send message to certain addresses.

I was thinking about using System.Net.Mail namespace (http://msdn.microsoft.com/en-us/library/system.net.mail.aspx) but the problem is I have no clue what is our SMTP address (I'm not really good at server side stuff). And also if I use System.Net.Mail and provide SMTP address doesn't that mean that I have to change it every time when the plugin is installed on another CRM instance. So I should probably add it as a part of my XML config file then.

Another option I was thinking was that I use the first example in this post and always when the email is sent I delete contacts I just created. Doesn't sound very good solution either.

How would you do this? I can life with extra email activities and one extra system user in CRM, but not with extra contacts.

1

1 Answers

1
votes

Based on your description I think best option is to send an email using System.Net.Mail as below. Try to find the SMTP you need to use.

var message = new MailMessage { From = new MailAddress("[email protected]") };
message.ReplyToList.Add(new MailAddress("[email protected]"));
message.To.Add(new MailAddress("[email protected]"));

message.Subject = "this is subject";
message.Body = "Email body text";
message.Priority = MailPriority.Normal;
var client = new SmtpClient("XXXXXXXX") { Timeout = 1000000 };               
client.Send(message);

This Link might be helpful for you.