473,666 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Http ServerUtilit
Imports System.Diagnost ics

Public Class Emailin
Inherits System.Web.UI Pag
Protected withEvents btnSubmit As System.Web.UI.W ebControls.Butt o
et
et

Private Sub btnSubmit(ByVal sender As System.Object, ByVal e As System.EventArg s) 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.co m" 'this work
msgMail.From = "we*******@comp any.com" 'this work
msgMail.Subject = "Quarterly Promotion Report" 'this works
msgMail.Bodyfor mat = Mailformat.Text 'this work
msgMail.Body = "Your Quarterly Promotion Report is attached" 'this work
msgMail.Attachm ents.Add(0) 'just guessing
msgMail.Attachm ents(0) = "qtrprorpt. pdf" 'just guessin
msgAttachment.G etValue(0) 'just guessin
SmtpMail.SmtpSe rver = "localhost" 'this work
SmtpMail.Send(m sgMail) 'this work
SmtpMail.Send(m sgAttachment) 'just guessin

Nov 22 '05 #1
2 3100
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*****@hotmai l.com> wrote in message
news:70******** *************** ***********@mic rosoft.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.Http ServerUtility
Imports System.Diagnost icss

Public Class Emailing
Inherits System.Web.UI Page
Protected withEvents btnSubmit As System.Web.UI.W ebControls.Butt on
etc
etc

Private Sub btnSubmit(ByVal sender As System.Object, ByVal e As System.EventArg s) 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.co m" 'this works msgMail.From = "we*******@comp any.com" 'this works msgMail.Subject = "Quarterly Promotion Report" 'this works msgMail.Bodyfor mat = Mailformat.Text 'this works msgMail.Body = "Your Quarterly Promotion Report is attached" 'this works msgMail.Attachm ents.Add(0) 'just guessing msgMail.Attachm ents(0) = "qtrprorpt. pdf" 'just guessing msgAttachment.G etValue(0) 'just guessing SmtpMail.SmtpSe rver = "localhost" 'this works SmtpMail.Send(m sgMail) 'this works SmtpMail.Send(m sgAttachment) '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*****@hotmai l.com> wrote in message
news:70******** *************** ***********@mic rosoft.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.Http ServerUtility
Imports System.Diagnost icss

Public Class Emailing
Inherits System.Web.UI Page
Protected withEvents btnSubmit As System.Web.UI.W ebControls.Butt on
etc
etc

Private Sub btnSubmit(ByVal sender As System.Object, ByVal e As System.EventArg s) 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.co m" 'this works msgMail.From = "we*******@comp any.com" 'this works msgMail.Subject = "Quarterly Promotion Report" 'this works msgMail.Bodyfor mat = Mailformat.Text 'this works msgMail.Body = "Your Quarterly Promotion Report is attached" 'this works msgMail.Attachm ents.Add(0) 'just guessing msgMail.Attachm ents(0) = "qtrprorpt. pdf" 'just guessing msgAttachment.G etValue(0) 'just guessing SmtpMail.SmtpSe rver = "localhost" 'this works SmtpMail.Send(m sgMail) 'this works SmtpMail.Send(m sgAttachment) 'just guessing

Nov 22 '05 #3

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

Similar topics

1
2429
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 file path when I want to send an email. I have tried "" and "/" that didn't work. Any help? My code is ------------------------------------------------------------------------
9
10953
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 working piece of code that emails jpg attachments but does not work with any other types of attachments. Could someone tell me how to modify this code to send other types of attachments like the one's stated above(especially PDF's)? Also how do I...
1
341
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 an excerpt from the program Imports System.Web.Mai Imports System.Web.HttpServerUtilit Imports System.Diagnostics Public Class Emailin Inherits System.Web.UI Pag
4
1442
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(), Subject.ToString(), Body.ToString(), 1)
5
1253
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 (same exact script as on other working computers), it looks like it posts back, but nothing is sent - nothing is in any of the MailRoot folders. This particular script has an attachment, but, just to make sure, I commented that line out and it...
5
1954
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 image shows up as an attachment in the target email box. If its possible, I would like to send HTML formatted emails where the
11
2086
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 MAPI tutorial, but it does a bit more than I want it to. What I would like to do is this: 1. Open the default mail client's compose window.
2
1802
by: andrii.akulov | last post by:
does anybody know how to email xml files using MIME/SMTP?
2
2594
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 file stored in the attachment field in each of the selected records to a specific e- mail address as an attachment to the e-mail. The pdf files can be zipped together or left separately. First off, Is this possible? I haven't found a lot of...
1
3263
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 attachment, i get the following error message... "adobe reader could not open <filenamebecuase it is either not a suppported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn't correctly...
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.