Mohammed Atef’s Technical blog

Send Email with attachment file

With the few line of codes you can send an e-Mail with attachment file. via .net application

Dim data As New Attachment(strFileName, System.Net.Mime.MediaTypeNames.Application.Octet)

‘Add time stamp information for the file.

Dim disposition As System.Net.Mime.ContentDisposition

disposition = data.ContentDisposition

disposition.CreationDate = System.IO.File.GetCreationTime(strFileName)

disposition.ModificationDate = System.IO.File.GetLastWriteTime(strFileName)

disposition.ReadDate = System.IO.File.GetLastAccessTime(strFileName)

‘ Add the file attachment to this e-mail message.


myMessage.Priority = MailPriority.High

‘Send the message.

Dim client As New System.Net.Mail.SmtpClient(“”)

‘Add credentials if the SMTP server requires them.

client.Credentials = New System.Net.NetworkCredential(“matef”, “123”)




February 8, 2009 - Posted by |, C#,VB.Net, Developement |

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: