Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hey! I Just need to be able to put in a gridview into an email body, open the email client that would send it, and in the client it opens a new email with the gridview in the body. I can code in VB, but all I am finding online is with asp.net using html. I can convert my gridview into an html file but idk where to go from there. PLEASE HELP lol. The gridview I have is also from ComponentOne, not that that matters. I feel like there should be a pretty simple way to do this. Any advice would be greatly appreciated.


UPDATE.

My main problem is that I can convert my gridview into an html FILE, but I don't know how to load it into the email body. When I say file I mean I have outputted the gridview to a .html in a folder on my computer. I can open it and it shows the gridview. I need that table in the body of the email, not as an attachment.
Posted
Updated 21-Mar-15 2:12am
v2
Comments
[no name] 20-Mar-15 12:12pm    
So what is it exactly that you need help with? Sending an email?

1 solution

Represent your grid view as HTML (whatever it is; it this is ASP.NET, you grid view is already HTML table) and send the message with Content-type "text/html", which will be automatically done if you set this property:
https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.isbodyhtml(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx[^].

Alternatively, you can use mail parts or alternative views and use this content type only for a view or a part:
https://msdn.microsoft.com/en-us/library/system.net.mail.alternateview(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/system.net.mail.attachment(v=vs.110).aspx[^].

Attachments (mentioned above) can have different ContentDisposition properties, so you can instruct the mail client to show the part inline, or make it as downloadable or separately-viewed attachment, and so on. Please see:
https://msdn.microsoft.com/en-us/library/system.net.mail.attachment.contentdisposition%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.net.mime.contentdisposition%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900