[RESOLVED] Sending a string through an email?
Is it possible to get a couple of strings and send them to an email address.
Code:
private void button1_Click(object sender, EventArgs e)
{
string Name;
string LastName;
string Address;
Name = textbox1.text;
LastName = textbox2.text;
Address = textbox3.text;
}
And Send the strings Name, Lastname, and Address to an email address.
I'm Guessing you would have to write it to a .txt file. Then somehow email it.
But i am not exactly sure how.
How do you do this?
Thanks in advance.
Re: Sending a string through an email?
Re: Sending a string through an email?
This should just about do what you need...
Code:
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.host.com"); //change this to match your smtp server
smtp.Send(new System.Net.Mail.MailMessage("[email protected]", [email protected]", "subject", "message"));
Re: Sending a string through an email?
Quote:
Originally Posted by foamy
This should just about do what you need...
Code:
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.host.com"); //change this to match your smtp server
smtp.Send(new System.Net.Mail.MailMessage("[email protected]", [email protected]", "subject", "message"));
That worked great, but i can't seem to get it to work with windows live or yahoo mail. Is is possible to do that?
Code:
"plus.pop.mail.yahoo.com" in the Incoming Mail (POP3, IMAP, or HTTP) Server box.
"plus.smtp.mail.yahoo.com" in the Outgoing Mail (SMTP) Server box.
Every time it tries to send a message when i use yahoo's SMTP the program crashes and Visual studio tells me it had an authentication error.
Code:
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("plus.smtp.mail.yahoo.com");
smtp.Send(new System.Net.Mail.MailMessage("[email protected]", "[email protected]", "New Contact!", "New Contact information"));
I think i have to add a yahoo username and password for myemail and then it should send it to my friends right?
But once again i am not sure how do this.
Re: Sending a string through an email?
I've only used this function on my own smtp server... so I'm not sure if what you're trying to accomplish is possible, not to mention allowed... I'm pretty sure that if you asked Yahoo, they'd tell you to please stop trying..
Re: Sending a string through an email?
No i think there is a way to put your yahoo username and password in the code. That way yahoo's smtp server could authenticate it. And send the email.
I'm pretty sure that is possible. Anyone have ideas?
Re: Sending a string through an email?
http://msdn.microsoft.com/en-us/libr...edentials.aspx
Take a look at that, it talks about sending credentials to the mail server.
Re: Sending a string through an email?
Quote:
Originally Posted by mwpeck
Can you show me an example of using a yahoo username and password?
Re: Sending a string through an email?
Ive been looking around i came up with this:
Code:
System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("[email protected]", "[email protected]", "New", "Account Name: " + accountname + "\nAccount Password: " + accountpassword);
MyMailMessage.IsBodyHtml = false;
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential("MyUsername", "Mypassword");
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 465);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.Send(MyMailMessage);
But every time i use it with my Gmail addresses the program stops responding.
Any ideas?
Re: Sending a string through an email?
That is your ISP's filter. They will only send email sent by the owner of the account's primary email address. Call them to get it removed