Custom Feature that sends email

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
5/24/2012 3:49:45 PM
Gravatar
Total Posts 5

Custom Feature that sends email

I am working on a custom feature that has a need to send an email to an address provided by the user. However I am having trouble finding any reference to connecting a custom feature into the mojoportal emailer that is already there. Is there a good way to connect my feature into the mojo email or should I just start coding this out from scratch?

5/24/2012 5:04:18 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Custom Feature that sends email

It's pretty simple, actually. Here is some sample code I used in one of our custom features. I built this by examining other email code throughout the mojoPortal source.

Using mojoPortal.Net;
Using mojoPortal.Web;

            SmtpSettings smtpSettings = SiteUtils.GetSmtpSettings();
            foreach (string email in myEmails)
            {
               EmailMessageTask messageTask = new EmailMessageTask(smtpSettings);

               messageTask.EmailFrom = siteSettings.DefaultEmailFromAddress;
               messageTask.EmailTo = email;
               messageTask.Subject = mySubject;
               messageTask.TextBody = myMessage;
               messageTask.SiteGuid = siteSettings.SiteGuid;
               messageTask.QueueTask();
            }
            WebTaskManager.StartOrResumeTasks();
 

 

5/24/2012 5:21:47 PM
Gravatar
Total Posts 5

Re: Custom Feature that sends email

That looks simple enough, I'll have to give it a try over the next few days. Thanks a ton for the quick response.

5/25/2012 6:47:33 AM
Gravatar
Total Posts 18439

Re: Custom Feature that sends email

You can also send email directly without a task. For just about anything you might need to do in a custom feature you can find example code in existing features that does something similar. For example to find code for sending email you could look at the code in the Contact Form feature.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.