public static string envio_correo(SqlString from, SqlString to, SqlString subject, SqlString htmlbody, SqlString textbody) { string gRequest = ""; try { Swagger Swagger = new Swagger(); Ent_Swagger data = new Ent_Swagger(); data.From = from; data.To = to; data.Subject = subject; data.HtmlBody = htmlbody; data.TextBody = textbody; //data.From = "*****@*****.**"; //data.To = "*****@*****.**"; //data.Subject = "titulo email"; //data.HtmlBody = "<h1>hola2</h1>"; //data.TextBody = "Que tal"; //string jsonData = js.Serialize(data); //var jsonData1 = (JsonConvert.DeserializeObject)data;//js.Serialize(data); //var serializer = new JavaScriptSerializer(); //var ss=n //var jsonData = JsonConvert.SerializeObject(data); //var jsondata = Correo.JsonConverter.Serialize(data); string jsonData = convert_object_jason(data); gRequest = Swagger.sendEmail(jsonData); //JavaScriptSerializer js = new JavaScriptSerializer(); //var jsonData = JsonConvert.DeserializeObject<>(data);//js.Serialize(data); //gRequest = Swagger.sendEmail(jsonData); } catch (Exception exc) { gRequest = exc.Message; } return(gRequest); }
public static string convert_object_jason(Ent_Swagger data) { string jason_query = ""; try { if (data != null) { jason_query = "{\"From\":" + "\"" + data.From.ToString() + "\"" + "," + "\"To\":" + "\"" + data.To.ToString() + "\"" + "," + "\"Subject\":" + "\"" + data.Subject.ToString() + "\"" + "," + "\"HtmlBody\":" + "\"" + data.HtmlBody.ToString() + "\"" + "," + "\"TextBody\":" + "\"" + data.TextBody.ToString() + "\"" + "}"; } } catch (Exception exc) { throw exc; } return(jason_query); }