Hide Attachments when using Net.Mail in VB.Net?

Hi,

I am currently using net.mail to send an email with 2 images which is working fine, however the images I have embedded in the html email also show as attachments.

is it possible to hide them from showing as attachments?

When using Outmail, I used to use..

.Attachments.Add("LINK TO IMAGE", , Len(.Body))

However this does not work using net.mail. Can anyone show me how to do this?
I have attached a code snippet of the code I am using to add the attachments.

Thanks,

Paul.
.Attachments.Add(New System.Net.Mail.Attachment("LINK TO IMAGE"))

Open in new window

m0tSiEAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
You said that you are embedding the photos in the email but the code snippets suggest that you are adding an attachment so the images would appear as attachments.
0
m0tSiEAuthor Commented:
Thanks,

I have tried using the code below to add it as a linked resource, however the image does not show in the email.

Dim logo As New Net.Mail.LinkedResource("Resources\logo.JPG")
        logo.ContentId = "Logo"

        Dim bar As New Net.Mail.LinkedResource("Resources\bar.JPG")
        bar.ContentId = "Bar"

I have then called the resources using <img src=cid:Logo> in the html of the email.

Any ideas?

Thanks,

Paul.
0
CodeCruiserCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

m0tSiEAuthor Commented:
Thanks.

I am now using the below code which uses the LinkedResource, however the paperclip icon still shows, along with the attachments.

Any idea how I can hide this?
        'create the mail message
        Dim mail As New MailMessage()
 
        'set the addresses
        mail.From = New MailAddress("TO")
        mail.To.Add("FROM")
 
        'set the content
        mail.Subject = "This is an email"
 
        'first we create the Plain Text part
        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", Nothing, "text/plain")
 
        'then we create the Html part
        'to embed images, we need to use the prefix 'cid' in the img src value
        'the cid value will map to the Content-Id of a Linked resource.
        'thus <img src='cid:companylogo'> will map to a LinkedResource with a ContentId of 'companylogo'
        Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.<img src=cid:companylogo>", Nothing, "text/html")
 
        'create the LinkedResource (embedded image)
        Dim logo As New LinkedResource("c:\temp\logo.gif")
        logo.ContentId = "companylogo"
        'add the LinkedResource to the appropriate view
        htmlView.LinkedResources.Add(logo)
 
        'add the views
        mail.AlternateViews.Add(plainView)
        mail.AlternateViews.Add(htmlView)
 
        Dim mailclient As New Net.Mail.SmtpClient
        Dim basicAuthenticationInfo As New Net.NetworkCredential("USER", "PASS")
        mailclient.Host = "SMTP SERVER"
        mailclient.UseDefaultCredentials = False
        mailclient.Credentials = basicAuthenticationInfo
        mailclient.Send(mail)

Open in new window

0
CodeCruiserCommented:
I dont see any reason why the attachement icon is still appearing.
0
m0tSiEAuthor Commented:
Cheers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.