Link to home
Start Free TrialLog in
Avatar of Ricky White
Ricky WhiteFlag for United States of America

asked on

How to send Email from a .Net project?

I would like to create a C#.Net project to send an email with an attachment.
Please advise how can this be achieved. Would VBScript be the easiest route?

Any links or resources would be appreciated.
 
Thanks!
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Import System.Web.Mail 

              Dim message As MailMessage
              message = New MailMessage ()
              message. To = "receiverID@domainName.Com"
              message. From = "sender@domainName.com"
              message. Subject = "Email Subject"
              message.BodyFormat = MailFormat.Html
              msgMail.Body = "<html><body><h2 " + 
                             "align = center>Hello World! " + 
                             "</h2></body></html>";

  MailAttachment attachment1 =
   new MailAttachment (@"c:\My Documents\OfficeFile1.doc");
  // Add Another One...
  MailAttachment attachment2 = 
   new MailAttachment ("d:\\Documents\\asp.netTurorial.doc");
  message.Attachments.Add (attachment1);
  message.Attachments.Add (attachment2);
 

              SmtpMail.Send (message)
              response. Write ("<BR><font color=red" + 
                               " face=verdana size=2> " + 
                               "Sent the mails. </font>")

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ricky White

ASKER

Thanks All!
Although all answers were helpful, I meant to select CodeCruiser's answer as the Best answer. Not sure how to change that.