Rated
Read 63,474 times
Related Categories
Sending Email With an Attachment
This code demonstrates how to send an email in VB.NET with an attachment. It currently attaches the file "C:\myattachment.zip" - in order to work, this file must obviously exist!
Dim oMsg As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()
oMsg.From = "noone@nobody.com"
oMsg.To = "someone@somewhere.com"
oMsg.Subject = "Email with Attachment Demo"
oMsg.Body = "This is the main body of the email"
Dim oAttch As MailAttachment = New MailAttachment("C:\myattachment.zip")
oMsg.Attachments.Add(oAttch)
SmtpMail.Send(oMsg)
James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.
Comments
-
Posted by k.ashish on 21 Jul 2008
this is the vb.net coding ....... note:- this is the coding which uses the gmail smtp server, u need to enter the valid email id and password of gmail, then only this will work... <... -
Posted by KIRTICHETAN on 16 Jul 2008
Hi
i want to devlop email application code with multipule attchement attchements. attchement should be with listbox.like i.e rediff style attchement so plz help me -
Posted by KIRTICHETAN on 16 Jul 2008
-
Posted by k.ashish on 07 May 2008
to krishna reddy..
hi krishna how r u...
i m making an application in vb.net to send email using smtp server...
but it dosnt work...
even it does not send mail to spam... if... -
Can You Please send the full details
i am little confused with the code
i send mails with out authentication works well
|