Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void SendMail(string toList, string from, string bccList, string subject, string body, string pass)
- {
- AppConfig.ReadSocksSettingsFromTxt();
- MailForward mf = new MailForward();
- Chilkat.MailMan mailman = new Chilkat.MailMan();
- bool success;
- success = mailman.UnlockComponent("MAIL12345678_***********");
- if (success != true)
- {
- MessageBox.Show("Component unlock failed");
- return;
- }
- mailman.HeloHostname = "Company-PC";
- mailman.SmtpAuthMethod = "LOGIN";
- // Set the SMTP server.
- mailman.SmtpHost = "smtp.company.com";
- mailman.SmtpSsl = true;
- mailman.StartTLS = true;
- mailman.SmtpPort = 23;
- // Set the SMTP login/password (if required)
- mailman.SmtpUsername = from;
- mailman.SmtpPassword = pass;
- mailman.VerboseLogging = true;
- // Create a new email object
- Chilkat.Email email = new Chilkat.Email();
- email.Subject = subject;
- email.Body = body;
- email.From = from;
- email.AddTo("", toList);
- // Call SendEmail to connect to the SMTP server and send.
- // The connection (i.e. session) to the SMTP server remains
- // open so that subsequent SendEmail calls may use the
- // same connection.
- success = mailman.SendEmail(email);
- if (success != true)
- {
- MessageBox.Show(mailman.LastErrorText);
- return;
- }
- success = mailman.CloseSmtpConnection();
- if (success != true)
- {
- MessageBox.Show("Connection to SMTP server not closed cleanly.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment