Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...

Am having one Gridview with some details and one Hyperlink (for Mail) and one
Label (Mail Status),to show the status of the mail.

In the Mail Status, the default text is "Not Sent".

Once i click and send the Mail from Hyperlink button, then the default text of Label will be chanded automatically to "Sent".

Plz give some codings to finish this task.

Warm regards,

Jaison Joe...
Posted
Comments
Please post the code where you sending mail.
I mean the codes which is executed on hyperlink click.

We will try to add the code for changing the label text there.
Jaison Joe 26-Feb-13 5:28am    
If i click the hyperlink buton, the the new webpage will appear and filled with some details for sending mail.

Protected Sub SendMail()
' Gmail Address from where you send the mail
Dim fromAddress = "yourname@gmail.com"
' any address where the email will be sending
Dim toAddress = Email.Text.ToString()
'Password of your gmail address
Const fromPassword As String = "xxxxxxxx"
' Passing the values and make a email formate to display
Dim subject As String = Subject.Text.ToString()
Dim body As String = "From: " + Name.Text & vbLf
body += "Email: " + Email.Text & vbLf
body += "Subject: " + Subject.Text & vbLf
body += "Message: " & vbLf + Message.Text & vbLf
' smtp settings
Dim smtp = New System.Net.Mail.SmtpClient()
If True Then
smtp.Host = "smtp.gmail.com"
smtp.Port = 587
smtp.EnableSsl = True
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New NetworkCredential(fromAddress, fromPassword)
smtp.Timeout = 20000
End If
' Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body)
End Sub
This is the function for mail sending.
But where is that hyperlink click event code.
I mean you must be using Gridview Rowcommand, I guess ...

Another thing is, if you are redirecting to another page for sending mail, then how will you show the Grid again...

Please reply.
Jaison Joe 26-Feb-13 6:26am    
This design page coding am using to redirect the page...

<asp:HyperLinkField HeaderText="SEND MAIL" NavigateUrl="mail.aspx"
Text="Send" DataNavigateUrlFields="email"
DataNavigateUrlFormatString="mail.aspx?email={0}" />
<asp:TemplateField HeaderText="MAIL STATUS" >

<asp:Label ID="lab1" runat ="server" Text="Not Sent" >

and using button event on webpage i can goback to the gridview page.
Ok I understood now.
Let me summarize.

-> You show one GridView.
-> There is one HyperLink for Sending mail.
-> On clicking of that you redirect to another page where you send the mail.
-> You have one back button on that page, by clicking on that you came back to the previous page where Grid was showing.

So, the following problem will restrict you to change the label to "Sent".
-> You can change the label on Hyperlink click. But as you are moving to another page and coming back from there, the Grid will again load, not with the changed label value.

Solution
If you can show that page on a modal popup and send the mail staying on the same page, then you can see the label text changed to "Sent".
Otherwise the Grid will load again with initial values.

Hope you get what I explained...

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