This article will provide you with short example of sending e-mails using the code.
You can sent an email programmatically through our API in following way:

CMS.EmailEngine.EmailMessage em = new CMS.EmailEngine.EmailMessage();
em.EmailFormat = CMS.EmailEngine.EmailFormatEnum.Html;
em.From = "from@mail.com";
em.Recipients = "to@mail.com";
em.Subject = "Subject";
em.Body = "body of email";

CMS.EmailEngine.EmailSender.SendEmail("site_name", em);

Please make sure you have SMTP server specified in site settings for e-mails being sent properly.

There are two basic variations of SendEmail method:

CMS.EmailEngine.EmailSender.SendEmail(em);
//or
CMS.EmailEngine.EmailSender.SendEmail("site_name", em);
//you can use CMS.CMSHelper.CMSContext.CurrentSiteName for site name


The first one sends e-mail using global settings, while the second one sends e-mail using settings for specified site. If user is using first variation and it doesn't work for him, it can be caused by he has specified SMTP settings only for appropriate site - not globally.




See also:


Applies to: Kentico CMS 3.1
Created on 11/24/2008 6:52:55 AM in E-mail Engine
 


Sitemap | Copyright 2008 Kentico software | Powered by Kentico