I have made a code using send gird api for send email.My email successfully send but i want to my email with proper format .
Please help me.
- var client = new SendGridClient(apiKey);
- var msg = new SendGridMessage()
- {
- From = new EmailAddress("[email protected]"),
- Subject = subject,
- PlainTextContent = htmlContent,
- HtmlContent = htmlContent
- };
- msg.AddTo(new EmailAddress(toEmail));
- var response = await client.SendEmailAsync(msg); --this is my c# code
this jquery and html code
- I have made a code using send gird api for send email.My email successfully send but i want to my email with proper format .
- Please help me.
- var client = new SendGridClient(apiKey);
- var msg = new SendGridMessage()
- {
- From = new EmailAddress("[email protected]"),
- Subject = subject,
- PlainTextContent = htmlContent,
- HtmlContent = htmlContent
- };
- msg.AddTo(new EmailAddress(toEmail));
- var response = await client.SendEmailAsync(msg); --this is my c# code
-
- this jquery and html code
- <div class="contact-main">
- <div class="container">
- <div class="row">
- <div class="col-md">
- <div class="back-shadow-contact ">
- <h2>Get in Touch</h2>
-
- <form id="form">
- <div class="form-row">
- <div class="form-group col-md-6">
- <input type="email" class="form-control form-contact" id="htmlContent" placeholder="Your Name" required="required"/>
- </div>
- <div class="form-group col-md-6">
- <input type="text" class="form-control form-contact" id="toEmail" placeholder="Your Email Address" required />
- </div>
- </div>
- <div class="form-row">
- <div class="form-group col-md-6">
- <input type="text" class="form-control form-contact" id="subject" placeholder="Subject" required />
- </div>
- <div class="form-group col-md-6">
- <input type="text" class="form-control form-contact" id="contact" placeholder="Your Contact No." required />
- </div>
- </div>
- <div class="form-group">
- <textarea class="form-control form-contact-msg" rows="5" id="htmlContent" placeholder="Enter Your Message" required></textarea>
- </div>
- <button class="submit-contact" type="button" id="btnSend">Submit</button>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div>
- </div>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
- <script type="text/javascript">
- $(function () {
- $("#btnSend").click(function (e) {
- e.preventDefault();
- var record = {
- "htmlContent": $("#htmlContent").val(),
- "toEmail": $("#toEmail").val(),
- "subject": $("#subject").val(),
- "htmlContent": $("#htmlContent").val(),
- "contact": $("#contact").val(),
- };
- $.ajax({
- url: '/Genric/SendMail',
- type: "GET",
- data: record,
- contentType: "application/json; charset=utf-8",
- success: function () {
- $("#form").reset();
- },
- error: function () {
- },
- failure: function () {
- }
- });
- });
- });
- </script>
My result is