SMTP no Web.Config

by Admin 6. August 2009 10:23

Pode parecer simples mas muita gente utiliza os parâmetros nos construtores da classe no momento de instanciar.

A configuração do smtp pode ser utilizada utilizando oseguinte trecho no web.config

    system.net>
        mailSettings>
            smtp deliveryMethod="Network" from="testuser@domail.com">
                network defaultCredentials="true" host="localhost" port="25" userName="kaushal" password="testPassword"/>
            /smtp>
        /mailSettings>
    /system.net>

O código para utilização pode ser assim. mas de livre alteração.

Dim mMailMessage As New MailMessage()
mMailMessage.From = New MailAddress() 'Do WebConfig
mMailMessage.To.Add(New MailAddress("Destinatario@email.com"))

If Not _com_copia = String.Empty Then
      mMailMessage.CC.Add(New MailAddress("ComCopia@email.com"))
End If

mMailMessage.Subject = _assunto 'Assunto
mMailMessage.Body = _corpo 'Corpo do E-mail
mMailMessage.IsBodyHtml = True ' HTML
mMailMessage.Priority = MailPriority.Normal 'Prioridade

Dim mSmtpClient As New SmtpClient() 'DoWebConfig
mSmtpClient.Send(mMailMessage)

Tags: , ,

ASP.NET | Dev Blog

Comments (1) -

Funny Love Quotes United States
8/11/2011 8:59:38 AM #

An impressive share, I just given this onto a colleague who was doing a bit analysis on this. And he in reality bought me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading extra on this topic. If potential, as you become experience, would you thoughts updating your weblog with more details? It is highly helpful for me. Massive thumb up for this blog post!

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Sobre Mim

Felipe Augusto Silva Lambert - Analista de Sistemas, experiência em 4 anos desenvolvimento ASP.NET, utilizando tecnologias ServerSide (Design Patterns, Linq, WCF, SQL Server, C# e VB.NET) e ClientSide (JavaScript e Jquery). técnico em Mecatrônica e bacharel em Ciência da Computação.

Widget Month List not found.

Unknown server tag 'blog:MonthList'.X