ANAT2403
asked on
AlternateView in mailmessage hide the body
I have a mailmessage with an image in it that I add with AlternateView .
AlternateView htmlView = AlternateView.CreateAltern ateViewFro mString("< img src=cid:companylogo>", null, "text/html");
LinkedResource logo = new LinkedResource("C:\\anat\\ images\\ii bmailg.gif ");
logo.ContentId = "companylogo";
htmlView.LinkedResources.A dd(logo);
message.AlternateViews.Add (htmlView) ;
When I add this I lose the body of my message. although I write
message.Body = "test email1......."
I don't see the body but only the image.
What is the problem here?
AlternateView htmlView = AlternateView.CreateAltern
LinkedResource logo = new LinkedResource("C:\\anat\\
logo.ContentId = "companylogo";
htmlView.LinkedResources.A
message.AlternateViews.Add
When I add this I lose the body of my message. although I write
message.Body = "test email1......."
I don't see the body but only the image.
What is the problem here?
ASKER
I managed to see both the image and the text but the image is seen only when it is in mode text.Html
and in this situation the text loses all its style format and appear as one long line.
How do I solve a situation like this that I have an image an a formatted text?
Anat
and in this situation the text loses all its style format and appear as one long line.
How do I solve a situation like this that I have an image an a formatted text?
Anat
Another way that might be useful is the Text.RichText type.
Bob
Bob
ASKER
I don't understand, I write it exactly as it is shown in all the resources and the image hide the text.
What's wrong here? help!!!!!
public static bool sendmail3(Page temppage)
{
MailMessage myMessage = new MailMessage();
myMessage.To.Add(new MailAddress("anat@business -solutions .co.il"));
myMessage.From = new MailAddress("anat@business -solutions .co.il");
myMessage.Subject = "How are you";
ContentType HtmlContentType = new ContentType("text/html");
AlternateView HtmlView = AlternateView.CreateAltern ateViewFro mString("< /b><img src=cid:JustinPic><b></b>" , HtmlContentType);
LinkedResource SomePic = new LinkedResource(@"C:\anat\i mages\upda te.gif");
SomePic.ContentId = "JustinPic";
HtmlView.LinkedResources.A dd(SomePic );
myMessage.AlternateViews.A dd(HtmlVie w);
ContentType PlainContentType = new ContentType("text/plain");
AlternateView PlainView = AlternateView.CreateAltern ateViewFro mString("H i, This is a text and I wish to see this text!!!!", PlainContentType);
myMessage.AlternateViews.A dd(PlainVi ew);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient ();
smtp.Send(myMessage);
return true;
}
What's wrong here? help!!!!!
public static bool sendmail3(Page temppage)
{
MailMessage myMessage = new MailMessage();
myMessage.To.Add(new MailAddress("anat@business
myMessage.From = new MailAddress("anat@business
myMessage.Subject = "How are you";
ContentType HtmlContentType = new ContentType("text/html");
AlternateView HtmlView = AlternateView.CreateAltern
LinkedResource SomePic = new LinkedResource(@"C:\anat\i
SomePic.ContentId = "JustinPic";
HtmlView.LinkedResources.A
myMessage.AlternateViews.A
ContentType PlainContentType = new ContentType("text/plain");
AlternateView PlainView = AlternateView.CreateAltern
myMessage.AlternateViews.A
System.Net.Mail.SmtpClient
smtp.Send(myMessage);
return true;
}
ASKER
I also discovered that it does not concern the image but the HTML text
The followin code also hide the text:
AlternateView plainView = AlternateView.CreateAltern ateViewFro mString("T his is the plain text view", new ContentType("text/plain")) ;
AlternateView htmlView = AlternateView.CreateAltern ateViewFro mString("" , new ContentType("text/html"));
msg.AlternateViews.Add(htm lView);
msg.AlternateViews.Add(pla inView);
The followin code also hide the text:
AlternateView plainView = AlternateView.CreateAltern
AlternateView htmlView = AlternateView.CreateAltern
msg.AlternateViews.Add(htm
msg.AlternateViews.Add(pla
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Crap--all you needed was <br>. I hate when I can't get the easy answers. I don't use the AlternateView, so I was thinking it was a problem with the arguments.
Thanks,
Bob
Thanks,
Bob
Dear Administrator, Page Editors,
For your kind notice :
ANAT2403 asked three questions as follows with almost the same problem:
https://www.experts-exchange.com/questions/21928822/AlternateView-in-mailmessage-hide-the-body.html
https://www.experts-exchange.com/questions/21928772/image-into-mail.html
https://www.experts-exchange.com/questions/21929525/image-in-mailmessage.html
and then mysteriously he found out the solution all by himself. After seeing, I beleive some good expert comments.
Then he requested the withdrawal of questions with points refunded.
How this can be possible that after seeing an alternative answer (May be from this ANAT2403 may have got hint from) you can withdraw the question.
THIS IS COMPLETELY AGAINST THE COMMUNITY PRINCIPAL.
For your kind notice :
ANAT2403 asked three questions as follows with almost the same problem:
https://www.experts-exchange.com/questions/21928822/AlternateView-in-mailmessage-hide-the-body.html
https://www.experts-exchange.com/questions/21928772/image-into-mail.html
https://www.experts-exchange.com/questions/21929525/image-in-mailmessage.html
and then mysteriously he found out the solution all by himself. After seeing, I beleive some good expert comments.
Then he requested the withdrawal of questions with points refunded.
How this can be possible that after seeing an alternative answer (May be from this ANAT2403 may have got hint from) you can withdraw the question.
THIS IS COMPLETELY AGAINST THE COMMUNITY PRINCIPAL.
ASKER
dear skvikram,
First of all I am she and not he.
It's true I asked the question 3 times because nobody gave me the solution and for a whole day I looked
everywhere to find it and I couldn't find it. So I asked again maybe someone else will have an idea.
(I was once told from the administrators of this site that if I don't get the appropriate answer I can ask the question again because the experts react the question a short time after it appears and then it is reacted less).
I gave you the solution and you saw it. Do you see in the solution something that you or someone else gave?
Believe me I would be happy to give you or anybody else the points but as I understand the rules of this site say not to
do it. I don't earn anything from the refunded points. I pay each month 10$ to get answers and all I want
is to get the correct answers. I develop a project alone and I have no one to advise with and this site
helps me alot. I know that you try to help me alot when I ask questions and you know that I don't
hesitate to accept answers. The truth is that I am a bit offended from this comment of you.
What would you do if you were in my place?
Anat
First of all I am she and not he.
It's true I asked the question 3 times because nobody gave me the solution and for a whole day I looked
everywhere to find it and I couldn't find it. So I asked again maybe someone else will have an idea.
(I was once told from the administrators of this site that if I don't get the appropriate answer I can ask the question again because the experts react the question a short time after it appears and then it is reacted less).
I gave you the solution and you saw it. Do you see in the solution something that you or someone else gave?
Believe me I would be happy to give you or anybody else the points but as I understand the rules of this site say not to
do it. I don't earn anything from the refunded points. I pay each month 10$ to get answers and all I want
is to get the correct answers. I develop a project alone and I have no one to advise with and this site
helps me alot. I know that you try to help me alot when I ask questions and you know that I don't
hesitate to accept answers. The truth is that I am a bit offended from this comment of you.
What would you do if you were in my place?
Anat
AlternateView htmlView= new AlternateView(body, MediaTypeNames.Text.Html);
message.AlternateViews.Add
Bob