var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var result = new string(
Enumerable.Repeat(chars, 8)
.Select(s => s[random.Next(s.Length)])
.ToArray());
Kod Parçası etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Kod Parçası etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
2 Mayıs 2015 Cumartesi
Metnin içindeki değerleri listeden replace etme
string htmlFile =
File.ReadAllText(
HttpContext.Current.Server.MapPath("~/Views/Shared/Mail/_RememberPassword.html"));
var htmlData = new Dictionary<string, string>();
htmlData.Add("{resetLinkId}", "link");
htmlFile = htmlData.Aggregate(htmlFile, (current, item) => current.Replace(item.Key, item.Value));
File.ReadAllText(
HttpContext.Current.Server.MapPath("~/Views/Shared/Mail/_RememberPassword.html"));
var htmlData = new Dictionary<string, string>();
htmlData.Add("{resetLinkId}", "link");
htmlFile = htmlData.Aggregate(htmlFile, (current, item) => current.Replace(item.Key, item.Value));
1 Mayıs 2015 Cuma
Remember password
public Result RememberPassword(string username)
{
try
{
var user = Context.Users.Find(username);
var smtpSection = (SmtpSection)ConfigurationManager.GetSection("mailSettings/no_reply");
var smtpClient = new SmtpClient(smtpSection.Network.Host, smtpSection.Network.Port)
{
Credentials = new NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password),
EnableSsl = smtpSection.Network.DefaultCredentials
};
var mailMessage = new MailMessage { From = new MailAddress(smtpSection.From, "Paü Dedikodu") };
mailMessage.To.Add(user.Email);
mailMessage.Subject = "Paudedikodu.com - Şifre sıfırlama";
#warning akif- link düzeltielecek. mail gönderme common service'e alınacak
mailMessage.Body = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/Views/Shared/Mail/_RememberPassword.html")).Replace("{0}","link");
mailMessage.IsBodyHtml = true;
smtpClient.Send(mailMessage);
return new Result { IsTrue = true, Message = "Şifre sıfırlama linkiniz mail adresinize gönderildi." };
}
catch (Exception)
{
return new Result { IsTrue = false, Message = "Bir hata oluştu" };
}
}
{
try
{
var user = Context.Users.Find(username);
var smtpSection = (SmtpSection)ConfigurationManager.GetSection("mailSettings/no_reply");
var smtpClient = new SmtpClient(smtpSection.Network.Host, smtpSection.Network.Port)
{
Credentials = new NetworkCredential(smtpSection.Network.UserName, smtpSection.Network.Password),
EnableSsl = smtpSection.Network.DefaultCredentials
};
var mailMessage = new MailMessage { From = new MailAddress(smtpSection.From, "Paü Dedikodu") };
mailMessage.To.Add(user.Email);
mailMessage.Subject = "Paudedikodu.com - Şifre sıfırlama";
#warning akif- link düzeltielecek. mail gönderme common service'e alınacak
mailMessage.Body = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/Views/Shared/Mail/_RememberPassword.html")).Replace("{0}","link");
mailMessage.IsBodyHtml = true;
smtpClient.Send(mailMessage);
return new Result { IsTrue = true, Message = "Şifre sıfırlama linkiniz mail adresinize gönderildi." };
}
catch (Exception)
{
return new Result { IsTrue = false, Message = "Bir hata oluştu" };
}
}
Asp.net resimli mail gönderme
Using the code
The following code is self explanatory. Here, we go:- Create a string that contains the HTML message to send.
- Create an
AlternateViewobject for supporting the HTML. - Create a
LinkedResourceobject for the image to send. - Add a
LinkedResourceobject to theAlternateViewobject. - Create a
Mailmesasgeobject and set itsTo,From, andSubjectproperties. - Add an
AlternateViewobject to theMailMessageobject. - Create an
SmtpClientobject and send theMailMessageobject.
Hide Copy Code
using System.Net.Mail;
string htmlBody = "<html><body><h1>Picture</h1><br><img src=\"cid:Pic1\"></body></html>";
AlternateView avHtml = AlternateView.CreateAlternateViewFromString
(htmlBody, null, MediaTypeNames.Text.Html);
// Create a LinkedResource object for each embedded image
LinkedResource pic1 = new LinkedResource("pic.jpg", MediaTypeNames.Image.Jpeg);
pic1.ContentId = "Pic1";
avHtml.LinkedResources.Add(pic1);
// Add the alternate views instead of using MailMessage.Body
MailMessage m = new MailMessage();
m.AlternateViews.Add(avHtml);
// Address and send the message
m.From = new MailAddress("rizwan@dotnetplayer.com", "Rizwan Qureshi");
m.To.Add(new MailAddress("shayan@dotnetplayer.com", "Shayan Qureshi"));
m.Subject = "A picture using alternate views";
SmtpClient client = new SmtpClient("smtp.dotnetplayer.com");
client.Send(m);
Kaydol:
Kayıtlar (Atom)
.net 6 mapget kullanımı
app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { var response = JsonConvert.Seriali...
-
XAMPP Apache MySQL PHP 5 PHP 4 1.8.3 2.4.9 5.6.16 5.5.11 1.8.2 2.4.9 5.5.36 5.4.27 1.8.1 2.4.3 5.5.27 5.4.7 1...
-
var mystring = "this,is,a,test" mystring . replace ( /,/ g , "newchar" ); DEMO: http://jsfiddle.net/d4N9s/
-
SELECT * FROM sys.Tables