how to use mailing system in C# [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i want to have an email system , when user done an action after that someone recieve an email in C#
so now how I can do that ??

You could use the .Net SmtpClient class as follows:
using System.Net.Mail;
// the e-mail details
String from = "me#server.com";
String to = "someone#server.com";;
// build up the message
MailMessage message = new MailMessage(from, to);
message.Subject = "My Title";
message.Body += "This is the biody of my message";
// create a server pointing to your mail server
String server = "mail.server.com";
// create a client
SmtpClient client = new SmtpClient(server);
client.Credentials = CredentialCache.DefaultNetworkCredentials;
// send the message
client.Send(message);

To send an email in .NET you could use the SmptClient class.

Related

C# Getting a lot of 0 ms reply while ping an IP address [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 months ago.
Improve this question
I have a bunch of ip address and trying to get reply with PingReply class but it's returns a lot of 0 ms while the ip address is live and reachable, why?
Ping srvPing = new Ping();
PingReply reply = srvPing.Send("195.228.152.149", 1000); // example ip which returns 0 ms
String ping = reply.RoundtripTime.ToString();
Debug.WriteLine(ping + "ms");
//output: 0ms
Please check the Status property from your reply variable. If the value of Status is not Success, you should not use the values returned by the RoundtripTime. The RoundtripTime property will return zero in that case.

Email Event Handling in c# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to implement event on email body i.e when i am sending mail using SmtpClient and after sending mail when user click anywhere in email body need to redirect to another page .
Please Help me.
For this you have to do few things:
Construct your mail body as html tags, enclose all contents inside an anchor tag with href points to the site to be redirected to.
set IsBodyHtml property of the MailMessage object to true
Send the mail
Try something like this:
string mailBodyHtml = "<a href='https://YourSiteName.com'> enclose the whole content here </a>
MailMessage mail = new MailMessage("fromAddress", "toAddress", "subject here", mailBodyHtml);
mail.IsBodyHtml = true;
SmtpClient client = new SmtpClient("localhost");
client.Send(mail);

Why does creating contact forms require a password? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So Im looking at having a contact form on my website where a person can type a message and send it, with the mesage going to my inbox.
But every time I see them online Ill see this:
System.Net.NetworkCredential("yourEmail#gmail.com", "YourPassword");
Why do I need to provide my password? When you send someone a regular email, you dont need THEIR password.
I also have security concerns. Ok, it's in a .cs file, but still, I dont like seeing my password in plain text there.
Also, what about if its for a big company? Does ebay have their password in plain text? It's something I doubt. How do other people do it?
You absolutely don't want the users password.
But for your contact form to be able to send a mail it needs to be send by a valid email client. Say for example you want to use the gmail server for your mail, you need to provide your credentials for it.
As for the second part of your question, please don't store these plain text in code. You can easily acces those from app.config / web.config
(for example see: Embed credentials for webclient in C# Console Application app.config?)
This is because you have your own SMTP relay and your own credentials.
So when setting up the mailer on your side, you need to specify a reply to email address.
Below is a working example of how do it
var m = new MailMessage { Subject = txtSubject.Text, IsBodyHtml = true, Body = emailOpeningLine + txtMessage.Text };
try
{
m.To.Add(new MailAddress("to");
m.From = new MailAddress("senders email address");
m.ReplyToList.Add("senders email address");
foreach (var attachment in Attactments)
{
m.Attachments.Add(new Attachment(attachment));
}
client.Send(m);
m.To.Clear();
m.Attachments.Clear();
}
catch (SmtpException esException)
{
}
catch (Exception ex)
{
}
Re your other questions, you can keep the passwords in a database, but remember to encrypt them.

How to send email in windows 10 apps using C#? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am working on a Windows 10 store app project. In my project I need to send confirmation email to client using my app. How can I do it without using any confirmation dialogue to show to user?
Confirmation email is like
"You order no "xy" has been confirmed."
using System.Net.Mail;
...
MailMessage mail = new MailMessage("you#yourcompany.com", "user#hotmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
reference: Send email with C#
Also as mentioned in the comments see this : MSDN Docs Send Email

How to send mail in c# instantly or at least perform it in background [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am using smtp client and mail message class of c# in order to send mail. The mail is to be send to one or at most two users at a time. However, the mail sending process is slow. it takes almost 5-8 second to send mail. Till this time, the page remains in idle position. Is there a way in asp.net c# to send mail instantly or at least redirect to another page and perform the mail sending operation at background so that user do not feel delay. Any suggestions!! I had done research on smtpclient.sendmailAsync but in using this property, mail was not send.. Thanks in advance
Task sendEmail = new Task(() =>
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me#mycompany.com");
mail.To.Add("you#yourcompany.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is a sample body";
//send the message
SmtpClient smtp = new SmtpClient();
smtp.Port = 465;
smtp.UseDefaultCredentials = true;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("youGmailAddress#gmail.com", "YourPassword");
smtp.Send(mail);
});
sendEmail.Start();

Categories

Resources