官术网_书友最值得收藏!

How to do it...

  1. Navigate to the RegisterUser function and make the following changes.
  2. Add a new string variable that accepts new input parameter named email from the request object:
         string firstname= inputJson.firstname;
string lastname=inputJson.lastname;
string profilePicUrl = inputJson.ProfilePicUrl;
string email = inputJson.email;

UserProfile objUserProfile = new
UserProfile(firstname,lastname,profilePicUrl,email);
  1. Add the following code immediately after instantiating the message object:
        message = new Mail();
message.Subject = "New User got registered
successfully.";
message.From = new Email("donotreply@example.com");

message.AddContent(new Content("text/html","Thank you so much
for getting registered to our site."));


Personalization personalization = new Personalization();
personalization.AddTo(new Email(email));
message.AddPersonalization(personalization);
....
....
....


public class UserProfile : TableEntity
{
public UserProfile(string lastName, string firstName,string
profilePicUrl,string email)
{
....
....
this.ProfilePicUrl = profilePicUrl;
this.Email = email;
}
....
....
public string ProfilePicUrl {get; set;}
public string Email { get; set; }
}
Instead of hardcoding, we are passing the values of the Subject, body (content), and From address dynamically via code. It's also possible to change the values and personalize based on the needs. Note that the email will be sent to the end user who got registered by providing an email address.
  1. Let's run a test by adding a new input field email to the test request payload, shown as follows:
        {
"firstname": "Praveen",
"lastname": "Sreeram",
"email":"example@gmail.com",
"ProfilePicUrl":"A Valid url here"
}
  1. This is the screenshot of the email that I have received:
主站蜘蛛池模板: 隆化县| 榕江县| 海林市| 诸城市| 淮安市| 阿合奇县| 新乐市| 乳山市| 万全县| 定结县| 北宁市| 阿图什市| 漯河市| 康保县| 霍州市| 宣恩县| 察雅县| 桦甸市| 福安市| 黄平县| 赤壁市| 茂名市| 周宁县| 静乐县| 孙吴县| 姜堰市| 惠安县| 南投县| 临泽县| 靖远县| 九龙县| 宁都县| 西乌| 淮阳县| 凤城市| 佛冈县| 宁武县| 津南区| 米易县| 中阳县| 鹰潭市|