Alex Rivera | Logout

Form with attachments upload and email sending

Asked 2011-06-08T16:23:53.463
18

I need to make form with a textarea and an image upload field. When somebody submit it I want it to send email (with text from textarea) with attachements (from input file upload field) to me.

My simple form looks like that:

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>        
            @Html.TextArea("Question");      
            <input type="file"/> 
            <input type="submit" value="Send" />

    </fieldset>

}

I found PHP scripts that are doing something like that, but how could I do it in ASP.NET MVC (could be with JavaScript)?

Edit
Report

1 Answer

3

MailMessage class in .NET should be able to handle that for you:

http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.attachments.aspx

Or are you looking for something more specific to your actual code? (e.g. how to read the file and add it to the attachment)?

answered 2011-06-08T16:28:02.583

Your Answer