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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:11:52+00:00 2026-05-17T00:11:52+00:00

Can anyone sort out the following code to make the adding an attachment to

  • 0

Can anyone sort out the following code to make the adding an attachment to an email work please.

Thanks

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="ISO-8859-1" Debug="true" %>
<% @Import Namespace="System.Web.Mail" %>
<% @Import Namespace="IO" %>

<script language="vb" runat="server">

Sub btnSendEmail_Click(sender as Object, e as EventArgs)

  Dim objMM as New MailMessage()

  objMM.To = "my@email.co.uk"
  objMM.From = "their@email.co.uk"
  objMM.BodyFormat = MailFormat.HTML
  objMM.Priority = MailPriority.Normal
  objMM.Subject = "Attachment test"
  objMM.Body = "There should be an attachment with this email"

  objMM.Attachments.Add(new MailAttachment("myimage.jpg"))

  SmtpMail.SmtpServer = "localhost"
  SmtpMail.Send(objMM)

End Sub

</script>

<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:Button runat="server" id="btnSendEmail" Text="Send email" OnClick="btnSendEmail_Click" />
    </form>
</body>
</html>
  • 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-17T00:11:52+00:00Added an answer on May 17, 2026 at 12:11 am

    I’m suspicious about

    new MailAttachment("myimage.jpg")
    

    I suspect you might want to get the full path e.g.

    new MailAttachment(Server.MapPath("Myimage.jpg"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can any one sort out my issue of memory leak in following code??? -(void)paint:(ImageWarper::WarpedImage
I've been trying to work out whether it's possible to do the following sort
Can anyone help me, I am trying to sort out some redirects using htaccess
can anyone help, i have problem doing a sort, I thought i had it
Can any one help me how to sort rows by relevance for the following
Can anyone tell me why this code would not be working? $('body').on('test', function() {
Can anyone please tell/suggest me how can i store and retrieve comments multiple/different values
need value advice and help me to sort out the following issue. function max_key($array)
I have written the following code to find out the missing sequence but i
I am getting this error on the following code, and cant figure out why.

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.