Calling API for Authenticating and Sending Email

Khathun s asked on March 6, 2017 12:56

Hi,

I have a form in user control(.ascx) after submitting on submit button it should call API for Authentication it should give me a session ID(The session id expires in 30 mins) using that session Id i need to call one more API and send an email to specific mail ID.

Please help me how can i proceed.

Recent Answers


Roman Hutnyk answered on March 6, 2017 14:59

Here are API examples:

  • Authentication
  • Email Notification:

    var msg = new EmailMessage(); var eti = EmailTemplateProvider.GetEmailTemplate("CourseRequestNotification", SiteContext.CurrentSiteID);

            if (eti == null)
            {
                EventLogProvider.LogException(this.GetType().Name, "NotifyCourseRequest", new Exception("Email template does not exist."));
                return;
            }
    
            var mcr = MacroResolver.GetInstance();
            mcr.SetNamedSourceData("user", request.Username);
            mcr.SetNamedSourceData("url", URLHelper.GetAbsoluteUrl(request.CourseNodePath));
            mcr.SetNamedSourceData("course", request.CourseName);
    
            msg.EmailFormat = EmailFormatEnum.Html;
            msg.From = eti.TemplateFrom;
            msg.BccRecipients = eti.TemplateBcc;
            msg.Recipients = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CourseRequestEmail");
            msg.Subject = eti.TemplateSubject;
    
            EmailSender.SendEmailWithTemplateText(SiteContext.CurrentSiteName, msg, eti, mcr, true);
    
1 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 6, 2017 16:27

Sounds like you are trying implement a registration process where you create a user and send a registration email with Authentication Token so user can click on it and be automatically logged in to your site?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.