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

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:
主站蜘蛛池模板: 高青县| 视频| 甘泉县| 进贤县| 休宁县| 昌平区| 尼玛县| 长岛县| 桃园县| 崇左市| 永泰县| 甘肃省| 霍山县| 武川县| 吉隆县| 安丘市| 晴隆县| 巴里| 沛县| 衡阳市| 勐海县| 静乐县| 固始县| 隆回县| 贵港市| 洛川县| 泸水县| 清苑县| 石楼县| 太原市| 迁安市| 安吉县| 梧州市| 右玉县| 合肥市| 资溪县| 新干县| 囊谦县| 泾川县| 巧家县| 炉霍县|