Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, February 7, 2009 8:18 AM
Hi all,
I have developed an addin for outlook, in my addin i m initiating new message which is posted to url of our website using http post and i wil get a link as a response. I need to insert this link in the message body and send it as email to selected contacts.
The problem is at the end of the message body i m appending a string "To continue discussion click here" and i need to make the string "here" as an hyperlink which directs to our page.
My code is here:
public bool Send_Mail(string Link)
{
try
{
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook.NameSpace NS = app.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder objFolder = NS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
Microsoft.Office.Interop.Outlook.MailItem objMail = (Microsoft.Office.Interop.Outlook.MailItem)objFolder.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
objMail.Body = txtMessage.Text + "\n\nTo continue discussion Click Here " + Link;
objMail.Subject = txtSubject.Text;
objMail.To = txtTo.Text;
objMail.CC = txtCc.Text;
objMail.Send();
return true;
}
catch
{
return false;
}
}
Here i m passing the link directly, it is working but I should not show the link like this instead i should make "here" as an hyperlink...
can anybody help me to do this...
Thanks & Regards,
Mahesh
All replies (7)
Wednesday, February 11, 2009 7:41 AM âś…Answered
Hi Paul,
Here instead of using objMail.Body i need to specify in objMail.HTMLBody. If I want to use HTMLBody then I need to specify the entire body of the page in HTML format... (I dono whether ther is any way to use both Body and HTMLBody)
I got sum code and also a dll which can be used to convert the content of rich text document to html format... :)
http://www.codeproject.com/KB/string/nrtftree.aspx <-- RTF to HTML
http://www.sgoliver.net/nrtftree.aspx <-- an update to the above
to use this directly i need to create a temp rtf file and store the formatted text in that and giv it's path as an input to the convertor class while creating an object of that class:
TraductorRtf t = new TraductorRtf("C:\tst.rtf");
string strhtml = t.traducir();
//objMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
objMail.HTMLBody = strhtml + "\n\nTo continue discussion click <a href=\" + Link + "\>here</ID></a>";
objMail.Subject = txtSubject.Text;
objMail.To = txtTo.Text;
objMail.CC = txtCc.Text;
objMail.Send();
Thanks & regards
Mahesh
Saturday, February 7, 2009 12:39 PM
Maheshs13,
objMail.Body = txtMessage.Text + "\n\nTo continue discussion Click <a Href=" + Link + ">Here</a>"
you may also to also set the objmail document type to html
Hope this helpsP Worthington
Tuesday, February 10, 2009 6:17 AM
Hi Worthington,
Thanks for reply...
I tried it but in mail it appears as code itself... :
To continue discussion Click <a Href=http://www.google.co.in>Here</a>
how to set the objMail doc type to html ?
Regards
Mahesh
Tuesday, February 10, 2009 12:32 PM
Hi Paul,
I tried that, I set the format as :
objMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
objMail.Body = txtMessage.Text + "\n\nTo continue discussion Click <a Href=\" + Link + "\>Here</a>";
but in an email it is showing as it is:
To continue discussion <a Href="http://www.google.co.in">Here</a>
Regards
Mahesh
Wednesday, February 11, 2009 6:56 AM
Hi P Worthington,
Is it correct wat i m doing? or do i need to set sum more properties?
Regards
Mahesh
Friday, February 13, 2009 2:34 AM
Hi Mahesh,
Thank you for sharing your helpful sample code and articles, I think they will surely be beneficial to other community members.
By the way, please don't duplicate post. Thank you!
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/6699ab09-3469-42d6-acba-4bf176b38cf9/
Best regards,
Guo
Friday, February 13, 2009 6:08 AM
Hi Guo,
I did not purposfully posted twice... I posted once n i saw it was not showing in "My Threads" so i thought it is not posted so i posted again... 2 questions i have posted twice.. and then I posted answers also twice so that other users should not think that this is unsolved problem....
now also if i post the new question it is not showing in My Threads or My Alerts immediatly........ it will show after sometimes, dono y???
any ways thanks for ur response
Regards,
Mahesh