Send mails, using SQL Server database mail, programmaticaly
Is there an API to use the mail functionality (included in SQL Se开发者_JAVA技巧rver) within a .Net program ?
Can I do it without using the stored procedures ?
try using System.Mail and system.net.mail but you have to configure mail settings for that.
If you have SQL Server Database Mail set up, you have an SMTP profile.
This means you can use the inbuilt .net classes to send mail using the same SMTP profile.
Some basic code:
var message = new MailMessage(from, to, subject, body)
var smtpClient = new SmtpClient("mySMTPserver.intra.net");
smtpClient.UseDefaultCredentials = true;
smtpClient.Send(message);
精彩评论