This project is read-only.
string APIKey = "878200a5-xxxx-45df-bbbb-c4a6a5d4f8e0";


// Create an instance of the api sending in the api key, and the type (note: Since an object is returned, sending "json" always on this version is suggested)

MandrillApi.MandrillApi _mapi = new MandrillApi.MandrillApi(APIKey, "json");


If the api key is correct, after the following line, the value of pong would be the string "PONG"
string pong = _Mapi.Ping();


// Here an anonymous object is created as the message parameters. There
// are additional values, you need to refer to the Mandrill ApI page,
// as at the time of this version, the Api is still changing.
object message = new
{
html = "html",
text = "text",
subject = "subject",
from_email = "fromemail",
from_name = "fromname",
to = new List<Recipient>(),
track_clicks = false,
track_opens = false,
auto_text = false,
url_strip_qs = false,
bcc_address = "bccemail@test.com",
merge = false
};

// Here the message created above is used in the send message
List<MandrillApi.Model.RecipientReturn> returnValue = _mapi.send(message);

Last edited May 26, 2012 at 2:57 AM by TomButlerjr, version 1

Comments

preetika Jun 23, 2014 at 6:44 AM 
I am using this code in MVC app

[HttpPost]
public ActionResult SendMail()
{


string APIKey = "poCApK8QlBVok4rkgzE5Bg";//"24Ps8J2udCo75GRjrbWCsw";


// Create an instance of the api sending in the api key, and the type (note: Since an object is returned, sending "json" always on this version is suggested)

MandrillApi.MandrillApi _mapi = new MandrillApi.MandrillApi(APIKey, "json");


//If the api key is correct, after the following line, the value of pong would be the string "PONG"
string pong = _mapi.Ping();


// Here an anonymous object is created as the message parameters. There
// are additional values, you need to refer to the Mandrill ApI page,
// as at the time of this version, the Api is still changing.

var recipients = new List<MailChimp.Types.Mandrill.Messages.Recipient>();

recipients.Add(new Mandrill.Messages.Recipient("preetikap@vinfotech.com", string.Empty));


object message = new
{
html = "html",
text = "text",
subject = "Hello",
from_email = "vinod@vinfotech.com",
from_name = "vinod",
to = recipients.ToArray(),
track_clicks = false,
track_opens = false,
auto_text = false,
url_strip_qs = false,
bcc_address = "",
merge = false
};

// Here the message created above is used in the send message
List<MandrillApi.Model.RecipientReturn> returnValue = _mapi.send(message);


return Json(true);

}

but it is not working not even sending email

momincse Aug 20, 2013 at 10:13 AM 
I tried this way. But giving the following exception:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task`1.get_Result()
at Mandrill.MandrillApi.SendMessage(EmailMessage message, DateTime send_at)
at WindowsFormsApplication8.Form1.button1_Click(Object sender, EventArgs e) in c:\users\imx\documents\visual studio 2010\Projects\WindowsFormsApplication8\WindowsFormsApplication8\Form1.cs:line 26
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication8.Program.Main() in c:\users\imx\documents\visual studio 2010\Projects\WindowsFormsApplication8\WindowsFormsApplication8\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

ddesborough Mar 10, 2013 at 10:21 PM 
There is a bug... see the issue tracker about the code using search.json in place of send.json

atifamin2002 Mar 9, 2013 at 8:10 AM 
I try this code but I didn't get any email, also I didn't get any error. API works fine but no Email.
Any reason?