473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

emailing attachment files in VB.Net

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 = "jo*@company.com" 'this work
msgMail.From = "we*******@company.com" '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

Nov 22 '05 #1
2 3062
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" <ol*****@hotmail.com> wrote in message
news:70**********************************@microsof t.com...
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 Dim msgMail As New MailMessage()
Dim msgAttachment As MailAttachment()

'file access code to get an email address

'file exist code to see if attachment file is available

'if email address and file attachment available
'set up message and attachment

msgMail.To = "jo*@company.com" 'this works msgMail.From = "we*******@company.com" 'this works msgMail.Subject = "Quarterly Promotion Report" 'this works msgMail.Bodyformat = Mailformat.Text 'this works msgMail.Body = "Your Quarterly Promotion Report is attached" 'this works msgMail.Attachments.Add(0) 'just guessing msgMail.Attachments(0) = "qtrprorpt.pdf" 'just guessing msgAttachment.GetValue(0) 'just guessing SmtpMail.SmtpServer = "localhost" 'this works SmtpMail.Send(msgMail) 'this works SmtpMail.Send(msgAttachment) 'just guessing

Nov 22 '05 #2
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" <ol*****@hotmail.com> wrote in message
news:70**********************************@microsof t.com...
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 Dim msgMail As New MailMessage()
Dim msgAttachment As MailAttachment()

'file access code to get an email address

'file exist code to see if attachment file is available

'if email address and file attachment available
'set up message and attachment

msgMail.To = "jo*@company.com" 'this works msgMail.From = "we*******@company.com" 'this works msgMail.Subject = "Quarterly Promotion Report" 'this works msgMail.Bodyformat = Mailformat.Text 'this works msgMail.Body = "Your Quarterly Promotion Report is attached" 'this works msgMail.Attachments.Add(0) 'just guessing msgMail.Attachments(0) = "qtrprorpt.pdf" 'just guessing msgAttachment.GetValue(0) 'just guessing SmtpMail.SmtpServer = "localhost" 'this works SmtpMail.Send(msgMail) 'this works SmtpMail.Send(msgAttachment) 'just guessing

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leon | last post by:
I am trying to send an email with an attachment. The problem is the attachment is stored in db where I have created a longblob field that contains the file so I have no idea how to specify the...
9
by: Bill | last post by:
I am trying to have the capability to email attachments. Specifically I want to be able to email a specific attachment that I name that may be a PDF document, text doc, etc. I already have a...
1
by: Bob-O | last post by:
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...
4
by: Farooq Khan | last post by:
hi, i'm using CDONTS component for emailing through one of my web service like this // Start of code // 'email' is the CDONTS object name email.send(EmailFrom.ToString(), EmailTo.ToString(),...
5
by: Elmo Watson | last post by:
I'm having weird problems emailing on the Win2003 Staging environment - - the same script runs on multiple other computers, but on this one, the smtp service is running, but when the send is done...
5
by: Steven Nagy | last post by:
Hi, I am sending an email in my .NET2.0 web app using: System.Net.Mail.Attachment System.Net.Mail.MailMessage I can successfully send an HTML email with a background image, however that...
11
by: Dustin Davis | last post by:
(using VB.NET 2005) I'm writing a desktop application that I would like to have the ability to email files. I've set up the SMTP portion, now I would like to have a MAPI option. I found a...
2
by: andrii.akulov | last post by:
does anybody know how to email xml files using MIME/SMTP?
2
by: nduerr | last post by:
I have a table with pdf files stored in an attachment data type field in a 2007 Access File. I would like to run a query that would select a group out of this table (easy part) then send the pdf...
1
by: =?Utf-8?B?U2FpIFZhamph?= | last post by:
Hi I am trying to send a .pdf document as an email attachment using net.mail. This email is being sent by a windows service application. After i receive the email, and when i try to open the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.