send an email to a recipient entered in a textbox [closed] - c#

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 9 years ago.
Improve this question
I have a C# Windows forms application with an address book. On the one form there is a text box which displays the contacts email address (from a data table). I'd like to have a button next to it, when clicked it will open up my email client, with the email address entered in.
I understand you can use System.Diagnostics.Process.Start(mailto:example#example.com) to send an email to the specified contact. But how can I get it to send it to the value entered in the text box

Sending emails by pushing it to a default mail client Process.Start('mailto:xxx') is not a good idea. There could be no default email client defined or the default application could just not be configured.
Either way, users will get messages coming not from your application but from the external application.
A better idea is to have an explicit email client configuration for your application and even yet better - allow users to configure email client.
By email client I mean:
SMTP server
port (default: 25)
username
password
With these, your application can easily send emails through the relay SMTP server:
http://msdn.microsoft.com/pl-pl/library/swas0fwc%28v=vs.110%29.aspx
MailMessage message = new MailMessage(from, to);
message.Subject = subject;
message.Body = body;
SmtpClient client = new SmtpClient(server);
client.Credentials = new NetworkCredentials( username, password );
client.Send(message);

Related

How to sending email in C# without entering password? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
How do you send an email without entering a password?
I made this:
client.Port = 587;
client.Host = "smtp.gmail.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = true;
client.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(emailtxt.Text.Trim());
mail.To.Add("myadressemail#gmail.com");
mail.Subject = "test";
mail.Body = "test";
mail.IsBodyHtml = true;
client.Send(mail);
Is it possible to send an email to Gmail without an authorization?
If not, are there any better alternatives?
Less secure apps are off.
Is it possible to send an email to Gmail without an authorization?
No
If not, are there any better alternatives?
As Mason mentions in the comments, the main alternatives are:
Use a mailto-link to open the users default email program to send the message. This will obviously reveal the email address, but presumably this would happen anyway if you reply to their email.
Setup a simple web-api that receives messages from your application and forwards them to an internal smtp server, or some other system to handle messages. If you want to reply to the user using email you would need to ask him/her for their email address. If you want to ensure the email is correct you could send an automated verification email to the address, and only forward the message once the address has been verified.
There is no real way getting around the need for authentication on the modern internet. The modern way of dealing with this in automated systems would typically be with certificates and API-keys, but email is a quite old protocol with more limited authentication methods.

Ways to send e-mail to registered users after 5 minutes in ASP.Net? [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 8 years ago.
Improve this question
In my ASP.net website i have done with sending email to users when they register their self but what i want that when a user register from my website it will automatically send email after 5 minutes instead of immediate sending after registration.
Here is my simple code :
private void SendEmail()
{
SmtpClient smtpClient = new SmtpClient();
MailMessage mailMsg = new MailMessage();
MailAddress fromAddress = new MailAddress("test#test.com");
smtpClient.Host = "mail.test.com";
smtpClient.Credentials = new NetworkCredential("test#test.com", "test");
smtpClient.Port = 25;
mailMsg.From = fromAddress;
mailMsg.To.Add(emailid);
mailMsg.Subject = "You are successfully registered";
mailMsg.Body = myString.ToString();
mailMsg.IsBodyHtml = true;
smtpClient.Send(mailMsg);
System.Threading.Thread.Sleep(500000);
}
I used System.Threading.Thread.Sleep(50000) to wait for 5 minutes but this did not help me out to get my exact needs.
I am thinking that i need to set a flag in database table against every registered user email and i will make a webservice which will execute after 5 minutes to see which email addresses needs to be send an email .
Is there any other little fast way to do this?
Store a registration email, and registration date in database (or in text file).
Make a simple different applicication which do the following:
-Checks the current date to the registration date plus 5 minutes.
-if its bigger, send out the email
-if the sending was success, remove the entry from the db
Build this application, and call the exe in every 4-5 minutes via cronjob or windows scheduler

How to add web page in windows forms project [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am having one Form "email.cs" in my project name as "Email Client"
In that form I am having one LinkLabel Control name as "Verify Email Address"
I designed one web Page name as "Verify.aspx".In this web page I have one TextBox Control
and one Button Control. When I enter any address into the textBox and click on the button it
immediately checks whether the email address entered into the textBox is actually present or
not on the "GMAIL-SERVER".
So my Question is that How can I Add this Web-Page into my Windows-Forms Project
You need to put some effort into this before asking on SO, try searching online and look at examples (For example here). You can just add a WebControl to the form.
You can use Regex to validate email addresses or try the following.
//NOTE: This code will not catch double periods, extra spaces. For more precision, stick to Regex.
public bool IsEmailValid(string emailAddress)
{
try
{
MailAddress m = new MailAddress(emailAddress);
return true;
}
catch (FormatException)
{
return false;
}
}
The Regex way to validate Email address:
String email = "test#gmail.com";
Regex regex = new Regex(#"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
+ "#"
+ #"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$";);
Match match = regex.Match(email);
if (match.Success)
//Email is has the right format.
else
//Email doesn't have the correct format.
But if your goal is to communicate with Gmail, then you will need to make use of:
GMAIL APIs - https://developers.google.com/gmail/

How to preview an HTML email before sending it. C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have developed a program which is sending HTML email using mail definition class.
Is it possible to preview the email before sending it.
Here is a piece of code using mailDefinition :
MailDefinition mailDefinition = new MailDefinition();
mailDefinition.BodyFileName = "C:/Html_Email.htm";
mailDefinition.From = "kami#gmail.com";
ListDictionary ldReplacements = new ListDictionary();
ldReplacements.Add("<%NearTeaser%>", "<b> Welcome to <b>" + nearteaser + "<b>");
ldReplacements.Add("<%Content%>", fulltext);
ldReplacements.Add("<%Weitere%>", "We have these offers for you: " + Weitere);
MailMessage mailMessage = mailDefinition.CreateMailMessage(mailTo, ldReplacements, new System.Web.UI.Control());
mailMessage.IsBodyHtml = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "hostname";
client.Send(mailMessage);
Every thing is working fine. I am curious if it is possible to preview the email before sending it.
Many thanks.
Before sending email display the contents of ldRelacements in a multitext box or in a panel/div.
MailDefinition class allows to create email messages from text files or strings.
Please go through http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.maildefinition(v=vs.110).aspx. It will give you some insights about MailDefinition class and examples.

Text Message Sending Free APIs [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I wanted to know that are there any Free APIs available for message sending?
I actually wanted to send a message to minimum 50 people at a time via my application. Is there any Free API available for message sending?
I want to send messages to their cell Numbers.. Is there any API for sending text messages to Cell Numbers?
You can do that by sending to the email txt address, all cell phones have email addresses you can send to. Number#provider.
* AT&T – cellnumber#txt.att.net
* Verizon – cellnumber#vtext.com
* T-Mobile – cellnumber#tmomail.net
* Sprint PCS - cellnumber#messaging.sprintpcs.com
* Virgin Mobile – cellnumber#vmobl.com
* US Cellular – cellnumber#email.uscc.net
* Nextel - cellnumber#messaging.nextel.com
* Boost - cellnumber#myboostmobile.com
* Alltel – cellnumber#message.alltel.com
2 possible solutions are:
Include the addresses that you want to hide as BCc in the email
Create an email group on your mail server (containing all the individual email addresses) and use that email group address in your C# code
or do like this ...
using System.Net.Mail;
then further down your code...
MailMessage message = new MailMessage();
message.CC.Add("allemailgroup#yourdomain.com");
foreach (string recipient in recipients) // assuming recipients is a List<string>
{
message.Bcc.Add(recipient);
}
EDIT: there are three ways to send text messages to cell
Using a GSM modem: Better when one wants to implement offline
applications and a very small number of SMS go every minute, usually
few 10s.
Using web service: Better when it is an online application and a very
few number of SMS go every minute, usually few 10s.
Using endpoints given by service the provider: Better when the number
of SMS exceeds a few 100s per minute. Service provider demands a
commitment
I strongly recommend you pls go through this link for more information
of at least 100,000 SMS per month.

Categories