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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:54:11+00:00 2026-05-11T23:54:11+00:00

sending mail along with embedded image using asp.net I have already used following but

  • 0

sending mail along with embedded image using asp.net

I have already used following but it can’t work

Dim EM As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage(txtFrom.Text, txtTo.Text)
        Dim A As System.Net.Mail.Attachment = New System.Net.Mail.Attachment(txtImagePath.Text)
        Dim RGen As Random = New Random()
        A.ContentId = RGen.Next(100000, 9999999).ToString()
        EM.Attachments.Add(A)
        EM.Subject = txtSubject.Text
        EM.Body = "<body>" + txtBody.Text + "<br><img src='cid:" + A.ContentId +"'></body>"
        EM.IsBodyHtml = True
        Dim SC As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient(txtSMTPServer.Text)
        SC.Send(EM)
  • 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-11T23:54:11+00:00Added an answer on May 11, 2026 at 11:54 pm

    If you are using .NET 2 or above you can use the AlternateView and LinkedResource classes like this:

    string html = @"<html><body><img src=""cid:YourPictureId""></body></html>";
    AlternateView altView = AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html);
    
    LinkedResource yourPictureRes = new LinkedResource("yourPicture.jpg", MediaTypeNames.Image.Jpeg);
    yourPictureRes.ContentId = "YourPictureId";
    altView.LinkedResources.Add(yourPictureRes);
    
    MailMessage mail = new MailMessage();
    mail.AlternateViews.Add(altView);
    

    Hopefully you can deduce the VB equivalent.

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

Sidebar

Related Questions

i am using System.Net.Mail for sending mail in asp.net.. how to delete attachment file
I am sending mail using classic ASP with the CDOSYS objects, but I would
I have developed one application for sending mail using vb.net. for that i'm using
i am using SMTP protocol for sending mail from my iphone app. but i
I'm using the mail() function to test sending emails with image file attachments to
I'm having trouble sending mail using SMTP from a Rails app. I have a
I am sending mail through my application. For that I am using following code.
I need to send mail using Gmail SMTP, but it's showing Failure sending mail.
for this app i'm following this example: http://pipoltek.blogspot.com/2008/02/sending-mail-using-gmail-smtp-server.html I can send emails, it looks
I am sending mail from .net application, my mail code is working fine but

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.