Currently my application is able to open up a Outlook email with a default recipient once a user has clicked Image button which is located inside a Grid View. The aspx code for this is as follows;
<asp:ImageButton ID="LinkEmail" OnClick="openClient" CommandArgument='<%# Eval("customerId") %>'
ToolTip="Send a Email to this customer" ImageUrl="~/SiteElements/Images/email_icon.jpg"
Width="16px" Height="16px" runat="server" />
I have a Bound Field Data Field with the ID "custEmail" which shows a customers email in the Data Grid if one is linked to their account. The code used to open the Outlook application was taken from this question and the only addition I have added is the address the email is being sent to;
Protected Sub openClient(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Out1 As Object
Out1 = CreateObject("Outlook.Application")
If Out1 IsNot Nothing Then
Dim omsg As Object
omsg = Out1.CreateItem(0) '=Outlook.OlItemType.olMailItem'
omsg.To = "sample.email@test.com"
'set message properties here...'
omsg.Display(True)
End If
What I would like to do is replace the sample email with the email showing for the customer in the data grid. When I try to do this like this;
omsg.To = custEmail
The code behind doesn't find this Bound Field Data Field.
How do I allow my code-behind to see the "custEmail" BoundField so I can popular "omsg.To" with a customers email address?