Tuesday 15 June 2010

asp.net - sending mail using recipient email stored in database -



asp.net - sending mail using recipient email stored in database -

i made form on there listview in details comes database such id, name & email id & checkboxes. want on selection of checkbox mail service id should select of row & mail service message should sent selected mail service id. code

<asp:listview id="lvcustomers" runat="server" groupplaceholderid="groupplaceholder1" itemplaceholderid="itemplaceholder1"> <layouttemplate> <table class="client_list" cellpadding="0" cellspacing="0"> <tr> <td style="padding: 10px; text-align: center; width: 15%; font-size: 16px; font-weight: bold; background: #c4dbf2; color: #fff">id </td> <td style="padding: 10px; text-align: center; width: 60%; font-size: 16px; font-weight: bold; background: #c4dbf2; color: #fff">company name </td> <td style="padding: 10px; text-align: center; width: 25%; font-size: 16px; font-weight: bold; background: #c4dbf2; color: #fff">email </td> <td style="padding: 10px; text-align: center; width: 25%; font-size: 16px; font-weight: bold; background: #c4dbf2; color: #fff">select 1 </td> </tr> <asp:placeholder runat="server" id="groupplaceholder1"></asp:placeholder> <tr> <td colspan="3"> <asp:datapager id="datapager1" runat="server" pagedcontrolid="lvcustomers" pagesize="20"> <fields> <asp:nextpreviouspagerfield buttontype="link" showfirstpagebutton="false" showpreviouspagebutton="true" shownextpagebutton="false" /> <asp:numericpagerfield buttontype="link" visible="false" /> <asp:nextpreviouspagerfield buttontype="link" shownextpagebutton="true" showlastpagebutton="false" showpreviouspagebutton="false" /> </fields> </asp:datapager> </td> </tr> </table> </layouttemplate> <grouptemplate> <tr> <asp:placeholder runat="server" id="itemplaceholder1"></asp:placeholder> </tr> </grouptemplate> <itemtemplate> <td> <%# eval("comp_id")%> </td> <td> <%# eval("client_name")%> </td> <td> <asp:label id="lbl" runat="server" text='<%# eval("email_id")%>' ></asp:label> </td> <td> <asp:checkbox id="checkbox1" runat="server" /> </td> </itemtemplate> </asp:listview>

vb code sending mail

protected sub sending_click(byval sender object, byval e system.eventargs) handles sending.click each item listviewitem in lvcustomers.items dim ck checkbox = directcast(item.findcontrol("checkbox1"), checkbox) if ck.checked seek dim mail service new mailmessage() dim smtpserver new smtpclient() mail.bcc.add(directcast(item.findcontrol("lbl"), label).text) mail.from = new mailaddress("something@gmail.com", "suraj_ email test") mail.subject = "email testing" mail.body = "http://www.something.com/feedback.aspx?" + mail.isbodyhtml = true smtpserver.port = 25 smtpserver.credentials = new system.net.networkcredential("something@gmail.com", "123") smtpserver.host = "smtp.gmail.com" smtpserver.enablessl = true smtpserver.send(mail) msgbox("mail sent") grab error_t exception msgbox(error_t.tostring) end seek end if next end sub

i not getting how specify recipients in mail.to.add() database rows selected in checkboxes

asp.net vb.net

No comments:

Post a Comment