需要获取电子邮件正文中的值

时间:2019-01-10 21:55:29

标签: scala apache-spark

val TimeFormat = 20:30:16
val count = 3500

我正在通过电子邮件正文中的spark scala程序发送上述值,但我无法获得这些值:

var bodyText = "Hello EveryOne, \n\n  No of records :  + count  \n  Total Time Taken to Load the Data:  + TimeFormat  \n\n\n Thanks \n ABC."

我收到的电子邮件如下

Hello EveryOne,

  No of records :  + count  
  Total Time Taken to Load the Data:  + TimeFormat  
 Thanks 

但是我需要电子邮件中的值。

1 个答案:

答案 0 :(得分:1)

您当前正在构建一个字符串文字(您的电子邮件正文)。您必须将其分成多个字符串文字,并将它们和常量连接起来:

var bodyText = "Hello EveryOne, \n\n  No of records : " + count + " \n  Total Time Taken to Load the Data: " + TimeFormat + " \n\n\n Thanks \n ABC."

另一个选择是's'字符串插值器。它允许您使用美元符号从字符串文字中引用变量。更多详细信息here

var bodyText = s"Hello EveryOne, \n\n  No of records : $count \n  Total Time Taken to Load the Data: $TimeFormat  \n\n\n Thanks \n ABC."