/
SupportModel.cs
49 lines (46 loc) · 1.56 KB
/
SupportModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;
public class SupportModel
{
public SupportModel()
{
}
public bool sendMail(EmailModel emailModel)
{
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";
mail.To.Add(new MailAddress("globaltechservicesnow@gmail.com"));
mail.From = new MailAddress("globaltechservicesnow@gmail.com");
client.Credentials = new System.Net.NetworkCredential("globaltechservicesnow@gmail.com", "haythamfaraz");
mail.Subject = emailModel.name + " | " + emailModel.service;
client.EnableSsl = true;
mail.IsBodyHtml = true;
mail.Body = "<html>"
+ "<body>"
+ "<div> <h2>Email: " + emailModel.email + " </h2> </br>"
+ "<h2> Name: " + emailModel.name + "</h2> </br>" +
"<h2> Phone number: " + emailModel.phoneNumber + "</h2> </br>" +
"<h2> Service: " + emailModel.service + "</h2> </br>" +
"<h2> More Information: " + emailModel.message+ "</h2> </br>"
+ "</div>"
+ "</body>"
+ "</html>";
try
{
client.Send(mail);
return true;
}
catch (Exception ex)
{
return false;
}
}
}