开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜