Compare Page Revisions
« Older Revision - Back to Page History - Current Revision
MailMessage message = new MailMessage(sender, recipient, subject, msg); SmtpClient mySmtpClient = new SmtpClient(mailServer); mySmtpClient.UseDefaultCredentials = true; mySmtpClient.Send(message);
SmtpClient smtp = new SmtpClient("127.0.0.1"); smtp.UseDefaultCredentials = true; smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; smtp.Port = 25; MailMessage msg = new MailMessage("somebody@emailhost.com", "somebody@emailhost.com", "My Email Subject", "This is a test of my SMTP service."); try { smtp.Send(msg); MessageBox.Show("Message sent!"); }
Imports System.Net Imports System.Net.Mail ... Public Sub SendEmail(ByVal recipient As String, ByVal sender As String, ByVal subject As _ String, ByVal messageBody As String, ByVal smtpServer As String) Dim smtpClient As New SmtpClient smtpClient.Host = smtpServer smtpClient.Port = 25 smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials Dim mailMessage As New MailMessage(sender, recipient, subject, messageBody) mailMessage.IsBodyHtml = True smtpClient.Send(mailMessage) End Sub
web.config
SmtpClient c = new SmtpClient()
<system.net> <mailSettings> <smtp deliveryMethod="Network" > <network host="10.0.0.2" port="25" defaultCredentials="true" /> </smtp> </mailSettings> </system.net>
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.