Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I want to attach html file to my email page.

The problem is that i got an error:

'Attachments' is not a member of 'Mail'

The error is in the line:

mail.Attachments.Add(attachment)

Why is that?

Thank's.

Posted

This Works For Me

 

This works for me.

 

Imports System.Web.Mail

.

.

.

'Create an instance of the MailMessage class

Dim mail AsNew MailMessage

'Set the To field

mail.To = "someone@someisp.com"

 

'Set the From field

mail.From = "someone@someisp.com"

 

'Set the CC field

mail.From = "someone@someisp.com"

 

'Set the Bcc field

mail.Bcc= "someone@someisp.com"

 

'Send the email in HTML format

mail.BodyFormat = MailFormat.Html

 

'Set the priority - options are High, Low, and Normal

mail.Priority = MailPriority.Normal

 

'Set the subject

mail.Subject = "Some Subject"

 

'Set the body

mail.Body = "<html><bodyThis is an HTML email with an attachment.</body></html>"

 

'Set attachments

mail.Attachments.Add(New MailAttachment("C:\somefile.html"))

'In order to specify a different SMTP mail server to use to send the message, 'set the SmtpServer property: '*************************************

'SmtpMail.SmtpServer = emailServerName

'*************************************

'Be careful, though. Since this is a static property,

'changing this value in one ASP.NET Web page will affect

'all ASP.NET Web pages using sending emails via the SmtpMail object.

'That is, if in one ASP.NET Web page you set the SmtpServer

'property to myMailServer, and then, in another ASP.NET Web page,

'do not specify the SmtpServer property, intending to use

'the default SMTP server, myMailServer will be used instead.

'For that reason, you should probably always specify

'the SmtpServer property - if you want to use

'the default SMTP server, simply do:

'***********************

SmtpMail.SmtpServer = "127.0.0.1"

 

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(mail)

 

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...