Hyperlink to email in asp.net

Discussion in 'ASP .Net' started by Steve Chatham, Feb 9, 2004.

  1. This ought to be simple, but I've not been able to figure out how to do
    this.

    I have a request to create a list from a sql database to be displayed in a
    datagrid on an asp web page.

    So far, so good.

    What I now want to do is one of 2 things:

    1. put a hyperlink at the bottom of the list, either in the footer or just
    below it, saying "Click here to email Mr. X about opportunity pricing". and
    what I'd want the hyperlink to do is create an email with the mailto (and a
    cc:) and a subject already filled in.

    An alternative:
    2. add a column to the datagrid, that would have similar info in it, but in
    this case, I'd like to grab the SKU number from the cell on that same row.
    The email would come up to Mr X, a cc: to Mr. Y and the Subject would be
    Opportunity Pricing - Item ABC" the next line would be similar, but it'd be
    ITEM DEF or whatever.

    Anyone have an idea as to how to do something that seems to be this simple?

    Maybe I need some more caffeine....

    Thanks,

    SC
     
    Steve Chatham, Feb 9, 2004
    #1
    1. Advertising

  2. Steve,

    Instead of using the MAPI capabilities of your Web browser, I would
    recommend that you use System.Web.Mail and the MailMessage class to send
    the e-mail. You can then specify who the mail is from, who it should go
    to, what the subject should be, what is contained within the body, etc.
    That way, the user doesn't have to see the mail message and then click
    Send. It just goes.

    If that's what you want to do, respond back with the language you are using
    and I'll write you a small sample.

    Jim Cheshire, MCSE, MCSD [MSFT]
    ASP.NET
    Developer Support


    This post is provided as-is with no warranties and confers no rights.


    --------------------
    >Reply-To: "Steve Chatham" <>
    >From: "Steve Chatham" <>
    >Subject: Hyperlink to email in asp.net
    >Date: Mon, 9 Feb 2004 10:42:24 -0500
    >Lines: 32
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 12.4.146.123
    >Path:

    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
    phx.gbl
    >Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208580
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >This ought to be simple, but I've not been able to figure out how to do
    >this.
    >
    >I have a request to create a list from a sql database to be displayed in a
    >datagrid on an asp web page.
    >
    >So far, so good.
    >
    >What I now want to do is one of 2 things:
    >
    >1. put a hyperlink at the bottom of the list, either in the footer or just
    >below it, saying "Click here to email Mr. X about opportunity pricing". and
    >what I'd want the hyperlink to do is create an email with the mailto (and a
    >cc:) and a subject already filled in.
    >
    >An alternative:
    >2. add a column to the datagrid, that would have similar info in it, but

    in
    >this case, I'd like to grab the SKU number from the cell on that same row.
    >The email would come up to Mr X, a cc: to Mr. Y and the Subject would be
    >Opportunity Pricing - Item ABC" the next line would be similar, but it'd

    be
    >ITEM DEF or whatever.
    >
    >Anyone have an idea as to how to do something that seems to be this simple?
    >
    >Maybe I need some more caffeine....
    >
    >Thanks,
    >
    >SC
    >
    >
    >
    >
     
    Jim Cheshire [MSFT], Feb 9, 2004
    #2
    1. Advertising

  3. &lt;a href="mailto:?Subject=Your Subject"&gt;Click here to ...&lt;/a&gt

    Tu-Thac

    ----- Steve Chatham wrote: ----

    This ought to be simple, but I've not been able to figure out how to d
    this

    I have a request to create a list from a sql database to be displayed in
    datagrid on an asp web page

    So far, so good

    What I now want to do is one of 2 things

    1. put a hyperlink at the bottom of the list, either in the footer or jus
    below it, saying "Click here to email Mr. X about opportunity pricing". an
    what I'd want the hyperlink to do is create an email with the mailto (and
    cc:) and a subject already filled in

    An alternative
    2. add a column to the datagrid, that would have similar info in it, but i
    this case, I'd like to grab the SKU number from the cell on that same row
    The email would come up to Mr X, a cc: to Mr. Y and the Subject would b
    Opportunity Pricing - Item ABC" the next line would be similar, but it'd b
    ITEM DEF or whatever

    Anyone have an idea as to how to do something that seems to be this simple

    Maybe I need some more caffeine...

    Thanks

    S
     
    =?Utf-8?B?VHUtVGhhY2g=?=, Feb 9, 2004
    #3
  4. James - tried to respond via email, but it bounced.

    I am writing in vb.

    Not 100% sure I will end up doing it your way, but I am interested in seeing
    how to do it, as there may be an opportunity to do another piece
    differently.

    Steve

    "Jim Cheshire [MSFT]" <> wrote in message
    news:...
    > Steve,
    >
    > Instead of using the MAPI capabilities of your Web browser, I would
    > recommend that you use System.Web.Mail and the MailMessage class to send
    > the e-mail. You can then specify who the mail is from, who it should go
    > to, what the subject should be, what is contained within the body, etc.
    > That way, the user doesn't have to see the mail message and then click
    > Send. It just goes.
    >
    > If that's what you want to do, respond back with the language you are

    using
    > and I'll write you a small sample.
    >
    > Jim Cheshire, MCSE, MCSD [MSFT]
    > ASP.NET
    > Developer Support
    >
    >
    > This post is provided as-is with no warranties and confers no rights.
    >
    >
    > --------------------
    > >Reply-To: "Steve Chatham" <>
    > >From: "Steve Chatham" <>
    > >Subject: Hyperlink to email in asp.net
    > >Date: Mon, 9 Feb 2004 10:42:24 -0500
    > >Lines: 32
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > >Message-ID: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: 12.4.146.123
    > >Path:

    >

    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
    > phx.gbl
    > >Xref: cpmsftngxa07.phx.gbl

    microsoft.public.dotnet.framework.aspnet:208580
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > >
    > >This ought to be simple, but I've not been able to figure out how to do
    > >this.
    > >
    > >I have a request to create a list from a sql database to be displayed in

    a
    > >datagrid on an asp web page.
    > >
    > >So far, so good.
    > >
    > >What I now want to do is one of 2 things:
    > >
    > >1. put a hyperlink at the bottom of the list, either in the footer or

    just
    > >below it, saying "Click here to email Mr. X about opportunity pricing".

    and
    > >what I'd want the hyperlink to do is create an email with the mailto (and

    a
    > >cc:) and a subject already filled in.
    > >
    > >An alternative:
    > >2. add a column to the datagrid, that would have similar info in it, but

    > in
    > >this case, I'd like to grab the SKU number from the cell on that same

    row.
    > >The email would come up to Mr X, a cc: to Mr. Y and the Subject would be
    > >Opportunity Pricing - Item ABC" the next line would be similar, but it'd

    > be
    > >ITEM DEF or whatever.
    > >
    > >Anyone have an idea as to how to do something that seems to be this

    simple?
    > >
    > >Maybe I need some more caffeine....
    > >
    > >Thanks,
    > >
    > >SC
    > >
    > >
    > >
    > >

    >
     
    Steve Chatham, Feb 9, 2004
    #4
  5. Steve,

    If you want to send the mail from the server using VB.NET, you would do
    this:

    Private Function SendEmail() As Boolean
    Dim sb As New StringBuilder("")
    Dim message As New MailMessage
    Dim boolSendSuccessful As Boolean

    boolSendSuccessful = True

    With sb
    .Append("This is my message." + vbCrLf)
    .Append("This is another line." + vbCrLf)
    End With

    With message
    .To = ""
    .From = ""
    .Subject = "Auto-Sent E-Mail"
    .Body = sb.ToString()
    End With

    Try
    SmtpMail.SmtpServer = "mail.mydomain.com"
    SmtpMail.Send(message)
    Catch e As Exception
    ' Do something to handle the exception...
    boolSendSuccessful = False
    End Try

    Return boolSendSuccessful

    End Function


    Jim Cheshire, MCSE, MCSD [MSFT]
    ASP.NET
    Developer Support


    This post is provided as-is with no warranties and confers no rights.

    --------------------
    >Reply-To: "Steve Chatham" <>
    >From: "Steve Chatham" <>
    >References: <>

    <>
    >Subject: Re: Hyperlink to email in asp.net
    >Date: Mon, 9 Feb 2004 11:38:41 -0500
    >Lines: 98
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 12.4.146.123
    >Path:

    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
    phx.gbl
    >Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208606
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >James - tried to respond via email, but it bounced.
    >
    >I am writing in vb.
    >
    >Not 100% sure I will end up doing it your way, but I am interested in

    seeing
    >how to do it, as there may be an opportunity to do another piece
    >differently.
    >
    >Steve
    >
    >"Jim Cheshire [MSFT]" <> wrote in message
    >news:...
    >> Steve,
    >>
    >> Instead of using the MAPI capabilities of your Web browser, I would
    >> recommend that you use System.Web.Mail and the MailMessage class to send
    >> the e-mail. You can then specify who the mail is from, who it should go
    >> to, what the subject should be, what is contained within the body, etc.
    >> That way, the user doesn't have to see the mail message and then click
    >> Send. It just goes.
    >>
    >> If that's what you want to do, respond back with the language you are

    >using
    >> and I'll write you a small sample.
    >>
    >> Jim Cheshire, MCSE, MCSD [MSFT]
    >> ASP.NET
    >> Developer Support
    >>
    >>
    >> This post is provided as-is with no warranties and confers no rights.
    >>
    >>
    >> --------------------
    >> >Reply-To: "Steve Chatham" <>
    >> >From: "Steve Chatham" <>
    >> >Subject: Hyperlink to email in asp.net
    >> >Date: Mon, 9 Feb 2004 10:42:24 -0500
    >> >Lines: 32
    >> >X-Priority: 3
    >> >X-MSMail-Priority: Normal
    >> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >> >Message-ID: <>
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> >NNTP-Posting-Host: 12.4.146.123
    >> >Path:

    >>

    >cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
     
    Jim Cheshire [MSFT], Feb 9, 2004
    #5
  6. How would you pick up the .from part for the specific users who are viewing
    the results?

    For instance, this would be used by both some of our salesreps as well as
    some customers. The users are all authenticated using NT Challenge
    response.

    I can hard code the TO: part of it, because that's always going to the same
    person.

    Also, is there a way they can edit the body of the message?

    SC

    "Jim Cheshire [MSFT]" <> wrote in message
    news:...
    > Steve,
    >
    > If you want to send the mail from the server using VB.NET, you would do
    > this:
    >
    > Private Function SendEmail() As Boolean
    > Dim sb As New StringBuilder("")
    > Dim message As New MailMessage
    > Dim boolSendSuccessful As Boolean
    >
    > boolSendSuccessful = True
    >
    > With sb
    > .Append("This is my message." + vbCrLf)
    > .Append("This is another line." + vbCrLf)
    > End With
    >
    > With message
    > .To = ""
    > .From = ""
    > .Subject = "Auto-Sent E-Mail"
    > .Body = sb.ToString()
    > End With
    >
    > Try
    > SmtpMail.SmtpServer = "mail.mydomain.com"
    > SmtpMail.Send(message)
    > Catch e As Exception
    > ' Do something to handle the exception...
    > boolSendSuccessful = False
    > End Try
    >
    > Return boolSendSuccessful
    >
    > End Function
    >
    >
    > Jim Cheshire, MCSE, MCSD [MSFT]
    > ASP.NET
    > Developer Support
    >
    >
    > This post is provided as-is with no warranties and confers no rights.
    >
    > --------------------
    > >Reply-To: "Steve Chatham" <>
    > >From: "Steve Chatham" <>
    > >References: <>

    > <>
    > >Subject: Re: Hyperlink to email in asp.net
    > >Date: Mon, 9 Feb 2004 11:38:41 -0500
    > >Lines: 98
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > >Message-ID: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: 12.4.146.123
    > >Path:

    >

    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
    > phx.gbl
    > >Xref: cpmsftngxa07.phx.gbl

    microsoft.public.dotnet.framework.aspnet:208606
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > >
    > >James - tried to respond via email, but it bounced.
    > >
    > >I am writing in vb.
    > >
    > >Not 100% sure I will end up doing it your way, but I am interested in

    > seeing
    > >how to do it, as there may be an opportunity to do another piece
    > >differently.
    > >
    > >Steve
    > >
    > >"Jim Cheshire [MSFT]" <> wrote in message
    > >news:...
    > >> Steve,
    > >>
    > >> Instead of using the MAPI capabilities of your Web browser, I would
    > >> recommend that you use System.Web.Mail and the MailMessage class to

    send
    > >> the e-mail. You can then specify who the mail is from, who it should

    go
    > >> to, what the subject should be, what is contained within the body, etc.
    > >> That way, the user doesn't have to see the mail message and then click
    > >> Send. It just goes.
    > >>
    > >> If that's what you want to do, respond back with the language you are

    > >using
    > >> and I'll write you a small sample.
    > >>
    > >> Jim Cheshire, MCSE, MCSD [MSFT]
    > >> ASP.NET
    > >> Developer Support
    > >>
    > >>
    > >> This post is provided as-is with no warranties and confers no rights.
    > >>
    > >>
    > >> --------------------
    > >> >Reply-To: "Steve Chatham" <>
    > >> >From: "Steve Chatham" <>
    > >> >Subject: Hyperlink to email in asp.net
    > >> >Date: Mon, 9 Feb 2004 10:42:24 -0500
    > >> >Lines: 32
    > >> >X-Priority: 3
    > >> >X-MSMail-Priority: Normal
    > >> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    > >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    > >> >Message-ID: <>
    > >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >> >NNTP-Posting-Host: 12.4.146.123
    > >> >Path:
    > >>

    >
    >cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
     
    Steve Chatham, Feb 9, 2004
    #6
  7. Steve,

    You would need to provide a way for your users to input their e-mail
    address to populate the From property.

    Can they modify the message? Yes. Simply give them a multi-line TextBox
    control.

    Jim Cheshire, MCSE, MCSD [MSFT]
    ASP.NET
    Developer Support


    This post is provided as-is with no warranties and confers no rights.

    --------------------
    >Reply-To: "Steve Chatham" <>
    >From: "Steve Chatham" <>
    >References: <>

    <>
    <>
    <>
    >Subject: Re: Hyperlink to email in asp.net
    >Date: Mon, 9 Feb 2004 15:14:46 -0500
    >Lines: 138
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >Message-ID: <#$>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 12.4.146.123
    >Path:

    cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
    phx.gbl
    >Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208669
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >How would you pick up the .from part for the specific users who are viewing
    >the results?
    >
    >For instance, this would be used by both some of our salesreps as well as
    >some customers. The users are all authenticated using NT Challenge
    >response.
    >
    >I can hard code the TO: part of it, because that's always going to the same
    >person.
    >
    >Also, is there a way they can edit the body of the message?
    >
    >SC
    >
    >"Jim Cheshire [MSFT]" <> wrote in message
    >news:...
    >> Steve,
    >>
    >> If you want to send the mail from the server using VB.NET, you would do
    >> this:
    >>
    >> Private Function SendEmail() As Boolean
    >> Dim sb As New StringBuilder("")
    >> Dim message As New MailMessage
    >> Dim boolSendSuccessful As Boolean
    >>
    >> boolSendSuccessful = True
    >>
    >> With sb
    >> .Append("This is my message." + vbCrLf)
    >> .Append("This is another line." + vbCrLf)
    >> End With
    >>
    >> With message
    >> .To = ""
    >> .From = ""
    >> .Subject = "Auto-Sent E-Mail"
    >> .Body = sb.ToString()
    >> End With
    >>
    >> Try
    >> SmtpMail.SmtpServer = "mail.mydomain.com"
    >> SmtpMail.Send(message)
    >> Catch e As Exception
    >> ' Do something to handle the exception...
    >> boolSendSuccessful = False
    >> End Try
    >>
    >> Return boolSendSuccessful
    >>
    >> End Function
    >>
    >>
    >> Jim Cheshire, MCSE, MCSD [MSFT]
    >> ASP.NET
    >> Developer Support
    >>
    >>
    >> This post is provided as-is with no warranties and confers no rights.
    >>
    >> --------------------
    >> >Reply-To: "Steve Chatham" <>
    >> >From: "Steve Chatham" <>
    >> >References: <>

    >> <>
    >> >Subject: Re: Hyperlink to email in asp.net
    >> >Date: Mon, 9 Feb 2004 11:38:41 -0500
    >> >Lines: 98
    >> >X-Priority: 3
    >> >X-MSMail-Priority: Normal
    >> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >> >Message-ID: <>
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> >NNTP-Posting-Host: 12.4.146.123
    >> >Path:

    >>

    >cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
     
    Jim Cheshire [MSFT], Feb 11, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. davetichenor
    Replies:
    1
    Views:
    915
    Eliyahu Goldin
    Oct 30, 2006
  2. Replies:
    2
    Views:
    507
    Eric Layman
    Apr 25, 2007
  3. Ken
    Replies:
    1
    Views:
    434
    Alvin Bruney
    Aug 16, 2003
  4. Dave
    Replies:
    0
    Views:
    1,003
  5. Paul Proefrock

    email hyperlink on ASP page

    Paul Proefrock, Nov 23, 2005, in forum: ASP General
    Replies:
    2
    Views:
    181
    PJones
    Nov 27, 2005
Loading...

Share This Page