StrataFrame Forum
Back
Login
Login
Home
»
Updates and Information
»
StrataFrame Users Contributed Samples
»
Sending mail through GMail SMTP server
Sending mail through GMail SMTP server
Post Reply
Like
1
Sending mail through GMail SMTP server
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Trent Taylor
Trent Taylor
posted 15 Years Ago
ANSWER
Topic Details
Share Topic
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
If you ever have the need to send mail through a GMail account, this sample may save you a few minutes. It isn't hard, but there are a few differences which require SSL and authentication.
//-- Establish Locals
SmtpClient smtp = new SmtpClient("smtp.gmail.com ", 587);
MailMessage msg = new MailMessage("reply@somewhere.com", "to@somewhere.com");
//-- Set the subject line
msg.Subject = "Hello World";
//-- Set the body (Plain text in this sample)
msg.Body = "Here is the body of the message.";
//-- Attach the file if necessary
msg.Attachments.Add(new Attachment(pathAndFileName));
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("myemail@gmail.com", "mypassword");
//-- Send the message
smtp.Send(msg);
Reply
Like
1
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Post Reply
Like
1
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search