i need send email single person, earlier emailer not more me, need in use mailchimp.
any code , regarding mailchimp? using asp.net.
you need have subscribe button in aspx page
<asp:button id="btnsubscribe" cssclass="btn btn-default" onclick="btnsubscribe_click" runat="server" text="go" />
in codebehind
along keys need have mailchimp dll need referenced project
protected void btnsubscribe_click(object sender, eventargs e) { try { // keys mail chimp , when signup in site // there can these keys , stored them in webconfig string apikey = convert.tostring(configurationmanager.appsettings["mailchimpapikey"]); string listid = convert.tostring(configurationmanager.appsettings["mailchimplistid"]); var options = new list.subscribeoptions(); options.doubleoptin = true; options.emailtype = list.emailtype.html; options.sendwelcome = false; var mergetext = new list.merges(txtsubscribe.text.trim(), list.emailtype.text) { {"fname", "webruster"}, {"lname", "web"} }; var merges = new list<list.merges> { mergetext }; var mcapi = new mcapi(apikey, false); var batchsubscribe = mcapi.listbatchsubscribe(listid, merges, options); if (batchsubscribe.errors.count > 0) // console.writeline("error:{0}", batchsubscribe.errors[0].message); scriptmanager.registerstartupscript(btnsubscribe, btnsubscribe.gettype(), "subscribe", "alert('given email address subscribed, thank you!')", true); // scriptmanager.registerstartupscript(btnsubscribe, btnsubscribe.gettype(), "subscribe", "alert('"+ batchsubscribe.errors[0].message + @"')", true); else // console.writeline("success"); scriptmanager.registerstartupscript(btnsubscribe, btnsubscribe.gettype(), "subscribe", "alert('you subscribed newsletter successfully.')", true); } catch (exception ex) { // errorlogger.clienterrorlogger(ex); throw ex; } }
Comments
Post a Comment