viernes, 24 de junio de 2011

Enviar correo desde ASP.NET con archivo adjunto

dim cuerpo as string="Donde va todo el texto del cuerpo"
Dim msg As New MailMessage(Me.txtEmail.Text, "info@dondevaya.com", "Prueba", cuerpo)
Dim mailClient As New SmtpClient("servidor SMTP", 25)
Dim cred As New System.Net.NetworkCredential("usuario", "clave")


msg.Attachments.Add(New Attachment(fupDoc.PostedFile.InputStream, fupDoc.FileName))

With mailClient
.UseDefaultCredentials = False
.Credentials = cred
.EnableSsl = False
.DeliveryMethod = SmtpDeliveryMethod.Network
.Send(msg)
End With