scala 无法通过SendInBlue发送电子邮件

u2nhd7ah  于 2023-10-18  发布在  Scala
关注(0)|答案(1)|浏览(169)

我正在使用SendInBlue Java API发送电子邮件,我在scala中编写了以下代码:

object SendInBlueApi extends App{
  val http : Sendinblue= new Sendinblue("https://api.sendinblue.com/v2.0","API_KEY");
  var data: Map[String, Any]= Map[String, Any]()
  data += ("to" -> "[email protected]")
  data += ("from" -> "[email protected]")
  data += ("subject" -> "My subject")
  data += ("text" -> "This is text")
  val str = http.send_email(data)
  println(str.toString)
}

但我得到这个错误:{“code”:“failure”,“message”:“valid 'to' email address required”,“data”:[]}

yacmzcpb

yacmzcpb1#

这是在map中添加元素的另一种方式:

object SendInBlueApi extends App{
  val http : Sendinblue= new Sendinblue("https://api.sendinblue.com/v2.0","API_KEY");
  var data: Map[String, Any] = Map[String, Any](
    data("to") -> "[email protected]",
    data("from") -> "[email protected]",
    data("subject") -> "My subject",
    data("text") -> "This is text"
  )
        println(str.toString)
}

相关问题