views:

141

answers:

1

I'm developing a web application in ASP.NET MVC, and I want users to be able to click on a new link and have it send an email through their default email client with information already filled in, how do I do this?

How would I do it if I wanted an email to be sent out when a new ticket was submitted in the help system?

+5  A: 

From MSDN:

<a href="mailto:[email protected]?
subject=MessageTitle&amp;
body=Message Content">
Contact Us</a>

If you wanted to send this email to all users of your application, you'd probably need to automate that part into a service that sends email automatically. You can send email through .NET without any interaction from the user.

Without having the particulars, I see you could do it as follows:

  1. User adds Ticket to the database.
  2. Asynchronous Service polls database for changes to that table.
  3. When it encounters a new ticket, sends an email to a list of users using information from this Stack Overflow question.
  4. The list of users would come from the database, or whatever mechanism you have in place to authenticate and authorize users. If it's Active Directory, it would come from members of that group.

Update

If the user wants to share that email with others, then why not let them pick who they want to share it with in Outlook?

At that point, you can leave off the email address and they can choose it when it pops up in their email editor:

<a href="mailto:?subject=MessageTitle&amp;body=Message Content">Contact Us</a>

That produces the following when you click on the link:

Outlook email

George Stocker
clear, simple, answered the question without snark.
Andrew Lewis
Thx for ur response George, but i have a different scenario.Let me clarify my question again. I have a web App accessed by some 100 users. they wanted to share information when they create a new ticket. so there would be link on each ticket details page to send that ticket Information.so when user clicks on that link it should open users outlook with new message. above code is specific to a perticular user i guess.Hope i communacated well this time.
Hari
but it should be done through user interaction. i do not want to send automated emails to everybody when ticket created. if the user who created ticket wants to share it with , lets say 2 other users, then user clicks on shareTicket link ...which should open outlook with new message.
Hari
is there anyway i can send message body with existing html that i have in ticketDetails view().just the way we construct message body when sending through SmtpClient
Hari
@Hari No. Your best bet would be to send through a server-side process to the user and let them forward it to their co-workers.
George Stocker
thanks for your help George
Hari