Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Image content as email in asp.net 2.0

Posted on 2007-07-26
4
Medium Priority
?
796 Views
Last Modified: 2013-11-26
hi
for our new site we want to  send the image content as mail(invitation)
But its giving me some error
Error means ,in rediffmail ,yahoo the image is coming as a content
In hotmail it is coming as an attachment..but after some times its opening
But in our domain mail server ...mahce.com....its coming as an attachment
y?
that also coming as  a bin attacthment///
while clicking that bin attachment its opening a html page and its showing the image
the image is .jpg image
is any thing error in the following code...
Please advise me for the same

 Dim mail As New MailMessage

        mail.From = New MailAddress("test@gmail.com")
        mail.To.Add("test@hotmail.com")

        mail.Subject = "Mail Fromtest"
        Dim plainView As AlternateView
        plainView = AlternateView.CreateAlternateViewFromString("Our Invitation", Nothing, "text/plain")
        Dim htmlView As AlternateView
        htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.<img src=cid:logo>", Nothing, "text/html")
        Dim logo As LinkedResource
        Dim path As String
        path = Server.MapPath("images/newmailcomicnew.jpg")
        logo = New LinkedResource(path)
        logo.ContentId = "logo"
        htmlView.LinkedResources.Add(logo)

        mail.AlternateViews.Add(plainView)
        mail.AlternateViews.Add(htmlView)
        Dim smtp As New SmtpClient

        smtp = New SmtpClient("127.0.0.1") ' //specify the mail server address
        smtp.Send(mail)

0
Comment
Question by:venkatca
3 Comments
 
LVL 9

Expert Comment

by:traxion
ID: 19575023
Different clients are going to handle the attachment differently.  If you want the image in the body, perhaps the attachment isn't the way to go.  Here is a scenario that's bandwidth friendly and I think would work well:

If you are mailing to a mailing list, let the users choose whether they can receive HTML or Text Only email.  

If Text Only is selected, send the image as an attachment.

If HTML is selected, do not attach the image, but rather link to the image from within the email and send an html email such as:

<html>
<body>
<img src="http://www.yourdomain.com/images/newmailcomicnew.jpg" />
</body>
</html>

This will ensure that the image gets displayed in the body of the message.
0
 
LVL 1

Author Comment

by:venkatca
ID: 19590808
Thanx
 It started working fine when I declared the mediatypename
e.g
 Dim logo As LinkedResource
        Dim path As String
        path = Server.MapPath("images/newmailcomicnew.jpg")
        logo = New LinkedResource(path)
logo.contentType.MediaType=Sysyem.Net.Mime.MediaTypeNames.Jpeg
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20432471
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question