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 1029235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:30:51+00:00 2026-05-16T12:30:51+00:00

I am generating an email via codebehind in C# in my asp.net application using

  • 0

I am generating an email via codebehind in C# in my asp.net application using the line below:

ClientScript.RegisterStartupScript(this.GetType(), "FormLoading", "window.open('mailto:AccountsPayable@xyzCorp.com?subject=Invoice for ABC Corp - " + ddlJobCode.SelectedItem.Text + " - Supporting Documentation', 'email');", true);

Is it possible to include an attachment programatically as well (if the user points to the attachment document via a browse button) ?

  • 1 1 Answer
  • 1 View
  • 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-16T12:30:52+00:00Added an answer on May 16, 2026 at 12:30 pm

    No I don’t think so… the mailto functionality is passed off by the browser to the default client. You have no other mechanism of talking to the client or even knowing if the mailto was even successful.

    If you want to add an attachment you will most likely have to send the email on behalf of them and do it server side.

    Edit: To do it server side you would need to post the page so that the Browse button pulls down the file server side and then you would need to construct the email and send it out via your own smtp server. Here is a quick code example, you will probably need to adapt it to work with your specific case:

    In your server side OnClick handler:

    protected void btnSendEmail_Click(object sender, EventArgs e)
    {  
        // this will get the file from your asp:FileUpload control (browse button)
        HttpPostedFile file = (HttpPostedFile)(fuAttachment.PostedFile);
        if ((file != null) && (file.ContentLength > 0))
        {
            // You should probably check file size and extension types and whatever
            // other validation here as well
            byte[] uploadedFile = new byte[file.ContentLength];
            file.InputStream.Read(uploadedFile, 0, file.ContentLength);
    
            // Save the file locally
            int lastSlash = file.FileName.LastIndexOf('\\') + 1;
            string fileName = file.FileName.Substring(lastSlash,
                file.FileName.Length - lastSlash);
    
            string localSaveLocation = yourLocalPathToSaveFile + fileName;
            System.IO.File.WriteAllBytes(localSaveLocation, uploadedFile);
    
            try
            {
                // Create and send the email
                MailMessage msg = new MailMessage();
                msg.To = "someone@somewhere.com";
                msg.From = "somebody@somebody.com";
                msg.Subject = "Attachment Test";
                msg.Body = "Test Attachment";
                msg.Attachments.Add(new MailAttachment(localSaveLocation));
    
                // Don't forget you have to setup your SMTP settings
                SmtpMail.Send(msg);
            }
            finally
            {
                // make sure to clean up the file that was uploaded
                System.IO.File.Delete(localSaveLocation);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating an HTML email using an ASP .NET user control, as follows
Trying to use a php generating the email address using the ID eg: peopleID
We're building a module for generating HTML for email newsletters. We've looked into using
I'm using System.Net.Mail to send an email message and want to make sure it
Generating a scaffold like this: rails generate scaffold User name:string email:string creates bits of
I am generating an email with dynamic content from a Haml template which parses
I am working on generating emails using Java. I would love to use some
I am having troubles generating a simple database form model. I am using: Doctrine
I am using a CMS system, which has a template for generating forms, with
I am using Facebook PHP SDK to authenticate the user. After generating the LoginUrl

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.