TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Robert Wiedeman
NA
5
2.4k
Mailing script doesn't work.
Sep 5 2012 5:25 AM
I need to make a mailing script. It needs to mail a certain string to me and save the string as a file. The saving part works but the mailing parts seem to fail? Could someone please tell me what I'm doing wrong here?
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.Net;
using System.Net.Mail;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void username_TextChanged(object sender, EventArgs e)
{
}
private void userplot_TextChanged(object sender, EventArgs e)
{
}
private void userreason_TextChanged(object sender, EventArgs e)
{
}
private void sendrequest_Click(object sender, EventArgs e)
{
string user = username.Text;
string plot = userplot.Text;
string reason = userreason.Text;
string all = user + " - " + plot + " - " + reason;
System.IO.File.CreateText (all);
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("
[email protected]
");
mail.To.Add("
[email protected]
");
mail.Subject = "Test Mail - 1";
mail.Body = all;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("
[email protected]
", "**********");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Reply
Answers (
5
)
Basics
How to create Registration page and login page using c# windows form application