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

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:
主站蜘蛛池模板: 平山县| 墨竹工卡县| 乡宁县| 清水河县| 博乐市| 鹰潭市| 长宁县| 闽侯县| 加查县| 缙云县| 汉中市| 无锡市| 米脂县| 永安市| 平果县| 诸城市| 台江县| 车致| 建昌县| 曲阜市| 白玉县| 沐川县| 左贡县| 台中县| 望谟县| 峨眉山市| 藁城市| 南靖县| 汤阴县| 资兴市| 通城县| 岳西县| 察哈| 普宁市| 兴安县| 东明县| 集安市| 普兰县| 平度市| 河曲县| 资阳市|