Attachment

shlvy

Regular
Joined
Oct 27, 2003
Messages
68
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.
 
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)



 
Back
Top