SpreadWebServcie.SendTemplateAttachments Method

 

使用模板发送单个邮件,并可以携带一个附件。

注:联系人将自动加入“Auto_+当前时间“的联系人列表,此函数允许重复发送,所以对应名单可能会出现重复联系人.请勿在其他邮件使用该联系人列表,以防止邮件重复发送.

public String SendTemplateAttachments (

string LoginEmail,

string APIKey,

string To,

string TemplateId,

string Subject,

string SubstitutionVars,

string CreativeLanguage

CampaignAttachment() files

)

参数

参数

类型

描述

LoginEmail

String

Spread账号的登录邮箱。

APIKey

String

Spread账号的密码或者API Key

To

String

收件者的邮箱地址。

TemplateId

String

TemplateId,实际上就是CampaignID。

Subject

String

邮件的主题。

SubstitutionVars

String

自定义的标签,Json格式,如:若在Campaign里面有个标签叫[CUSTOM],那么这个可以传入参数:{"[CUSTOM]":"Value"}。

CreativeLanguage

String

Creative的语言代码,如:en,en-us,zh-tw,zh-cn。

fils

CampaignAttachment()

附件对象数组。

返回结果

String 表示邮件发送的结果。"Sent success" 表示成功,其他表示失败。

例子

string LoginEmail = "spread@reasonables.com" ;

string APIKey = "spread" ;

 

//Define recipient email

string To = "noclone@reasonables.com" ; 

 

  //Content Information

string TemplateId = "1" ;

string Subject = "Title" ;

string SubstitutionVars = "{\"[CUSTOM]\":\"Value\"}" ;

 

//Language Information

string CreativeLanguage = "en" ; 

 

//Attachment Information

SpreadWebService. CampaignAttachment[] files = new SpreadWebService. CampaignAttachment [2];

 

SpreadWebService. CampaignAttachment AttachmentA = new SpreadWebService. CampaignAttachment ();

AttachmentA.file = File .ReadAllBytes( "Desktop/FileA.txt" )

AttachmentA.fileType = ".jpg" ; 

AttachmentA.displayName = "FileA.jpg" ; 

 

SpreadWebService. CampaignAttachment AttachmentB = new SpreadWebService. CampaignAttachment ();

AttachmentB.file = File .ReadAllBytes( "Desktop/FileB.txt" )

AttachmentB.fileType = ".jpg" ; 

AttachmentB.displayName = "FileB.jpg" ; 

 

files[0] = AttachmentA ; 

files[1] = AttachmentB ; 

 

//Create a SpreadWebService object and use its method.

SpreadWebService MySpread = new SpreadWebService ();

string result = MySpread.SendTemplateAttachments(LoginEmail,APIKey,To,TemplateId,
Subject,SubstitutionVars,CreativeLanguage,files);

参见

SpreadWebService Class | Spread Web Service Namespace

Campaign Class