Hyperlink to email in asp.net

S

Steve Chatham

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
 
J

Jim Cheshire [MSFT]

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
(e-mail address removed)

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


--------------------
 
G

Guest

<a href="mailto:[email protected]?Subject=Your Subject">Click here to ...</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
 
S

Steve Chatham

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 said:
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
(e-mail address removed)

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


--------------------
Reply-To: "Steve Chatham" <[email protected]>
From: "Steve Chatham" <[email protected]>
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: <[email protected]>
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
 
J

Jim Cheshire [MSFT]

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 = "(e-mail address removed)"
.From = "(e-mail address removed)"
.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
(e-mail address removed)

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

--------------------
Reply-To: "Steve Chatham" <[email protected]>
From: "Steve Chatham" <[email protected]>
References: <[email protected]>
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: <[email protected]>
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 said:
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
(e-mail address removed)

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


--------------------
Reply-To: "Steve Chatham" <[email protected]>
From: "Steve Chatham" <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 12.4.146.123
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
 
S

Steve Chatham

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 said:
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 = "(e-mail address removed)"
.From = "(e-mail address removed)"
.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
(e-mail address removed)

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

--------------------
Reply-To: "Steve Chatham" <[email protected]>
From: "Steve Chatham" <[email protected]>
References: <[email protected]>
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: <[email protected]>
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 said:
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
(e-mail address removed)

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


--------------------
Reply-To: "Steve Chatham" <[email protected]>
From: "Steve Chatham" <[email protected]>
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: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 12.4.146.123
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top