Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:56:07+00:00 2026-05-25T12:56:07+00:00

I am implementing a razor contact form on Umbraco CMS, which includes inline C#

  • 0

I am implementing a razor contact form on Umbraco CMS, which includes inline C# script to create and send an email using .Net’s MailMessage. The end user now needs to be able to upload a file, which gets added to the email as an attachment.

From my knowledge, the only way to do this is by uploading to the disk and then loading the attachment from the disk.

Is it possible to upload and attach without writing to disk? Keep in mind there is no code-behind or controller – this is all in-line razor logic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:56:08+00:00Added an answer on May 25, 2026 at 12:56 pm

    You need to pass the InputStream from the uploaded file to the MailMessage’s Attachment constructor:

    if(IsPost && Request.Files.Count > 0){
        var file = Request.Files[0];
        var fileName = file.FileName;
        var attachment = new Attachment(file.InputStream, fileName);       
        ...
        ...
    

    Make sure that (unless you are using the FileUpload Helper) you set the form’s method to POST, add an enctype attribute with a value of multipart/form-data, and that you provide your input type=file with a name attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When implementing error-handling using the built-in validation-helpers on a strongly-typed view, you usually create
Implementing constant contact in asp.net
When implementing a Matrix construct using arrays, which would be more efficient? Using a
implementing publishActivity in PHP using the REST API using this code: $activity = array(
I implementing a EventQueue and get notified when AWTEvents are send. I wait till
While implementing a design using nested generic collections, I stumbled across those limitations apparently
Im implementing a B-tree in C++,I have a stack which saves pairs . my
Implementing the basic algorithm using last array as a pivot in Java, is it
Implementing custom DataAnnotationsModelMetadataProvider in ASP.NET MVC2. Assuming the object that is being rendered looks
I`m implementing a custom filesystem on Ubuntu using Fuse, but I need to trap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.