Attach file and send it as an email
-
How do you create a form to attach a file and then send it as an email with an attachment? Im hoping to send it to my hotmail account. Any help would be appreciated. thanks
-
How do you create a form to attach a file and then send it as an email with an attachment? Im hoping to send it to my hotmail account. Any help would be appreciated. thanks
I don't know what to do exactly without trying it myself, but maybe this can get you started in the right direction.. To upload a file put a file field on your form: When the page is posted back to the server you can access the uploaded file by calling the PostedFile property of the file field: fileUpload.PostedFile Use the InputStream property of the PostedFile to do whatever you have to, for example: Dim img As System.Drawing.Image img = img.FromStream(fileUpload.PostedFile.InputStream) Create the email: Dim email as New System.Web.Mail.MailMessage email.Attachements.Add(img) email.From = "from@hotmail.com" email.To = "to@hotmail.com" email.Subject = "test" email.Body = "hi" Send the email (make sure the Smtp service is running in your IIS server): SmtpMail.Send(email)