Skip Navigation Links.
展开 最小化

SpreadWebServcie.SendTemplateAttachment Method

使用模板發送單個郵件,並可以携帶一個附件。

注:聯絡人將自動加入“Auto_+當前時間“的聯絡人名單,此函數允許重複發送,所以對應名單可能會出現重複聯絡人.請勿在其他郵件使用該聯絡人名單,以防止郵件重複發送。

public String SendTemplateAttachment (

string LoginEmail,

string APIKey,

string To,

string TemplateId,

string Subject,

string SubstitutionVars,

string CreativeLanguage

Byte[] Attachment

string AttachmentName

)

Public function SendTemplateAttachment( _

LoginEmail As String, _

APIKey As String, _

To As string, _

TemplateId As String, _

Subject As String, _

SubstitutionVars As String, _

CreativeLanguage As Byte(), _

Attachment As String, _

AttachmentName As String _

) As String

No sample for PHP.
No sample.

參數

參數

類型

描述

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

Attachment

Byte()

附件的文件流。

AttachmentName

String

郵件中要顯示的附件的名稱。

返回結果

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

byte[] Attachment = File .ReadAllBytes( "xxxx/1234.txt" );

string AttachmentName = "1234.txt" ;

 

//Create a SpreadWebService object and use its method.

SpreadWebService MySpread = new SpreadWebService ();

 

string result = MySpread.SendTemplateAttachment(LoginEmail,APIKey,To,TemplateId,
Subject,SubstitutionVars,CreativeLanguage,Attachment,AttachmentName);

Dim LoginEmail As String = "spread @reasonables.com"

Dim LoginPassword As String = "spread"

 

  'Define recipient email

Dim To As String = "myedm@edm.com"

 

 'Content Information

Dim TemplateId As String = "1"

Dim Subject As String = "Title"

Dim SubstitutionVars As String = "{""[CUSTOM]"":""Value""}"

 

 'Language Information

Dim CreativeLanguage As String = "en"

 

 'Attachment Information

Dim Attachment As Byte() = File .ReadAllBytes( "xxxx/1234.txt" )

Dim AttachmentName As String = "1234.txt"

 

'Create a SpreadWebService object and use its method.

Dim MySpread As New SpreadWebService

Dim Result As String = MySpread.SendTemplateAttachment(LoginEmail,APIKey,To,TemplateId, Subject,SubstitutionVars,CreativeLanguage,Attachment,AttachmentName)

        /**
     * @name     SendTemplate
     * @function send template email with attachment
     * @return
     *   'Invalid Email Address'                                            
     *   'Information required'                                             
     *   'LoginEmail and Password do not match'                             
     *   'Sent failed'                                                      
     *   'Your email has submitted successfully and will by send out soon.' 
     *   'Sent success'                                                     
     */
    public function SendTemplate($loginEmail,$APIKey,$to,$templateId,$subject,$substitutionVars,$creativeLanguage,$attachment,$attachmentName){
        $sendParam = array(
            'LoginEmail'    => $loginEmail,
            'APIKey'      => $APIKey,
            '[To]'  => $to,
            'TemplateId'          => $templateId,
            'Subject'          => $subject,
            'SubstitutionVars'      => $substitutionVars,
            'CreativeLanguage'            => $creativeLanguage,
            'Attachment'       => $attachment,
            'AttachmentName'          => $attachmentName
        );
        $Client=new SoapClient("http://service.rspread.com/Service.asmx?WSDL");
        error_log( json_encode( $sendParam )."__param" );
        $sendResult = $Client -> SendTemplateAttachment( $sendParam ); 
        return $sendResult;
    }
         
No sample.