Monday, 10 April 2017

How to get the mail xontent from any xml file

I am using nodemailer in my mean stack applicaion. I am sending successfully mails using it.

Now I am trying to send the mail by depending upon the situation. For this I am storing the mail content in xml page and i need to get that mail content depending upon the key word in the html tag of nodemailer.

For ex: If a user registered then registration mail will be sent by getting registration key word in xml file.

XML file as shown below

   <?xml version="1.0" standalone="yes"?>
<MailContent>
  <registration>
    <AfterSignUp>
     <html><body><p>
      Hello #FirstName #LastName
     </p>
      <p>
      <br/>
      You recently registered for #ProjectName.To complete your registration, please <a href="#URL">Click Here </a> to confirm 'your' account.
      </p> 
     <br/>
      <p>
      Warm Regards,
      </p>
      <br/>
      <p>
      System Administrator
      </p>
      <br/>
      <p>
      #ProjectName.
      </p></body></html></AfterSignUp>
    <SignUpSubject>Registration confirmation for #ProjectName</SignUpSubject>
  </registration>

  <ForgotPassword>
    <ForgetContent><html><body><p>
      Hello #FirstName #LastName
      </p>
      <p>
      You have requested to have your password reset for your account at #ProjectName.
      </p>
      <p>
      Click the below link to reset your account password
      </p>
      <p>
      <a href="#URL">Reset Password </a>
      </p>
      <br/>
       <p>
      Warm Regards,
      </p>
      <br/>
      <p>
      System Administrator
      </p>
      <br/>
      <p>
       #ProjectName.
      </p></body></html></ForgetContent>
    <ForgetSubject>#ProjectName password recovery.</ForgetSubject>
  </ForgotPassword>

</MailContent>

Node mailer mailoptions as below

    let mailOptions = {
    from: 'mailid', // sender address
    to: 'mailid', // list of receivers
    subject:, // Subject line

    html: '' // html body
};

In above how to get that xml file content in nodemailer options



via charan tej

No comments:

Post a Comment