emailing attachment files in VB.Net

G

Guest

Need your help in sending an email message with an attachment in my VB.Net program. Sending a body message is no problem. I don't know how to use the attachment property in an emai

Following is an excerpt from the program

Imports System.Web.Mai
Imports System.Web.HttpServerUtilit
Imports System.Diagnostics

Public Class Emailin
Inherits System.Web.UI Pag
Protected withEvents btnSubmit As System.Web.UI.WebControls.Butto
et
et

Private Sub btnSubmit(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Clic
Dim msgMail As New MailMessage(
Dim msgAttachment As MailAttachment(

'file access code to get an email addres

'file exist code to see if attachment file is availabl

'if email address and file attachment availabl
'set up message and attachmen

msgMail.To = "(e-mail address removed)" 'this work
msgMail.From = "(e-mail address removed)" 'this work
msgMail.Subject = "Quarterly Promotion Report" 'this works
msgMail.Bodyformat = Mailformat.Text 'this work
msgMail.Body = "Your Quarterly Promotion Report is attached" 'this work
msgMail.Attachments.Add(0) 'just guessing
msgMail.Attachments(0) = "qtrprorpt.pdf" 'just guessin
msgAttachment.GetValue(0) 'just guessin
SmtpMail.SmtpServer = "localhost" 'this work
SmtpMail.Send(msgMail) 'this work
SmtpMail.Send(msgAttachment) 'just guessin
 
A

Anand N [MVP]

Hi Bob,

Check out my following articles:

http://www.developer.com/net/asp/article.php/3096831
http://www.developer.com/net/asp/article.php/3287361

I hope this helps

--
Regards,
Anand N
Microsoft MVP
NetAns Technologies
www.netans.com
Affordable/Reliable Web Hosting Services
---------------------------------
www.learnXpress.com
www.dotnetalbum.com

Bob-O said:
Need your help in sending an email message with an attachment in my
VB.Net program. Sending a body message is no problem. I don't know how to
use the attachment property in an email
Following is an excerpt from the program:

Imports System.Web.Mail
Imports System.Web.HttpServerUtility
Imports System.Diagnosticss

Public Class Emailing
Inherits System.Web.UI Page
Protected withEvents btnSubmit As System.Web.UI.WebControls.Button
etc
etc

Private Sub btnSubmit(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top