Last active
November 10, 2017 11:47
-
-
Save AnanoAspanidze/5d8d87477b53dc7b26ac1351198615f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//returns string | |
PopulateBody(); | |
//returns bool | |
SendEmai("email","subject", "body", true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="email-background" style="background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;padding-top:10px;padding-bottom:10px;padding-right:10px;padding-left:10px;"> | |
<div class="email-container" style="max-width:500px;background-color:#fff;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;margin-top:0;margin-bottom:0;margin-right:auto;margin-left:auto;overflow:hidden;border-radius:5px;"> | |
<p style="margin-top:20px;margin-bottom:5px;margin-right:20px;margin-left:20px;font-size:16px;color:#666;line-height:1.2;font-weight:300;"> | |
konnichiwa ^^ | |
</p> | |
<p style="margin-top:5px;margin-bottom:20px;margin-right:20px;margin-left:20px;font-size:16px;color:#666;line-height:1.2;font-weight:300;"> | |
ამ მეილმა გააუქმა გამოწერა: {Email} | |
</p> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string PopulateBody() | |
{ | |
string body = string.Empty; | |
using (StreamReader reader = new StreamReader(Server.MapPath("~/mail/htmlMail.html"))) | |
{ | |
body = reader.ReadToEnd(); | |
} | |
//body = body.Replace("{variableName}", variableValue); | |
return body; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool SendEmail(string userMail, string subject, string body, bool isHtml) | |
{ | |
try | |
{ | |
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); | |
mail.From = new System.Net.Mail.MailAddress("[email protected]"); | |
mail.To.Add(userMail); | |
mail.Subject = subject; | |
mail.Body = body; | |
mail.IsBodyHtml = isHtml; | |
System.Net.Mail.SmtpClient SmptServer = new System.Net.Mail.SmtpClient("in-v3.mailjet.com"); | |
SmptServer.Port = 587; | |
SmptServer.Credentials = new System.Net.NetworkCredential("497c9a7a91307238c7eb41e4fce8d53c", "8cfc2ef7bdb10ce4a0ac5ee629d11ae5"); | |
SmptServer.EnableSsl = true; | |
SmptServer.Send(mail); | |
//System.Net.Mail.SmtpClient SmptServer = new System.Net.Mail.SmtpClient("smtp.gmail.com"); | |
//SmptServer.Port = 587; | |
//SmptServer.Credentials = new System.Net.NetworkCredential("[email protected]", "anano2016"); | |
return true; | |
} | |
catch | |
{ | |
return false; | |
} | |
} | |
//gmail smtp service-ის მეშვეობით მეილის გაგზავნის პირველი მცდელობის შემდეგ თქვენს ელ.ფოსტაზე | |
//(რომლითაც აგზავნით მეილს) მოგივათ მეილი, რომელიც მოგთხოვთ, დაბლა დაწიოთ უსაფრთხოება, | |
//რომ კოდით შეძლოთ მეილის გაგზავნა. დაადასტურეთ და შემდეგ ისევ შეძლებთ ყველაფრის უკან დაბრუნებას. | |
//თუ ამის შემდეგ მეილი მაინც ვერ გააგზავნეთ, დალოგინდით, ამ ლინკზე შედით, Allow less secure apps: | |
//ON მონიშნეთ და ახლიდან სცადეთ. | |
//https://stackoverflow.com/questions/20906077/gmail-error-the-smtp-server-requires-a-secure-connection-or-the-client-was-not | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment