Net-informations.com
SiteMap  | About    

ASP.NET Email Attachment

The System.Net classes uses to communicate with other applications by using the HTTP, TCP, UDP, Socket etc. In the previous chapter we saw how to SMTP email from ASP.NET describes how to send an email with text body . Here in this chapter we are trying to send and email with attachment file.

email-attachment

System.Net.Mail.Attachment class is used with the MailMessage class for sending an email with attachment. Attachment content can be a String, Stream, or file name. You can specify the content in an attachment by using any of the Attachment constructors.

VB.Net

C#

The following ASP.NET program shows how to send an email with an attachment from a Gmail address . The Gmail SMTP server name is smtp.gmail.com and the port using send mail is 587 . Here we are using NetworkCredential for password based authentication.

VB.Net

C#

The above code you have to replace username and password with you gmail user name and password. Also you have to provide the from address as your gmail address.

VB.Net

C#

There is file upload control using in this program for uploading the file from your system to web server.

Default.aspx


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.cs
default.aspx.vb






net-informations.com (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.