【问题标题】:Exacttarget Emails: how to dynamically attach multiple files?Exacttarget 电子邮件:如何动态附加多个文件?
【发布时间】:2015-03-05 00:10:58
【问题描述】:

我正在研究如何使用精确目标发送电子邮件附件:(可能是多个)

http://help.exacttarget.com/en-US/documentation/exacttarget/content/email_attachments/

我无法按照以下说明对其进行硬编码:

%%=AttachFile("Portfolio","Example1")=%%
%%=AttachFile("Portfolio","Example2")=%%
%%=AttachFile("Portfolio","Example3")=%%
%%=AttachFile("Portfolio","Example4")=%%
%%=AttachFile("Portfolio","Example5")=%%

因为我需要发送的附件数量不同。

有人知道我如何以编程方式实现这一目标吗?

非常感谢!

【问题讨论】:

    标签: exacttarget


    【解决方案1】:

    %%[IF Condition1 THEN]%%
    %%=AttachFile("Portfolio","Example1")=%%

    %%[ELSEIF 条件2 THEN]%%
    %%=AttachFile("Portfolio","Example1")=%%
    %%=AttachFile("Portfolio","Example2")=%%

    %%[ELSEIF 条件3 THEN]%%
    %%=AttachFile("Portfolio","Example3")=%%

    %%[ELSEIF Condition4 THEN]%%
    %%=AttachFile("Portfolio","Example3")=%%
    %%=AttachFile("Portfolio","Example4")=%%

    %%[ELSEIF Condition5 THEN]%%
    %%=AttachFile("Portfolio","Example1")=%%
    %%=AttachFile("Portfolio","Example5")=%%

    %%[ELSE ENDIF]%%

    【讨论】:

    • 我了解您在做什么,并且我同意这适用于大多数情况。但是,如果我事先不知道附件的数量,并且我的数据库中有一个包含 10 个附件的记录,那么在这种情况下,如果/else 有 5 个就不能令人满意。我想知道 AMP 脚本中是否有一个循环可以实现这个目标。
    【解决方案2】:

    快速link 更深入地了解 AMPScript 中的附件功能

    如果没有更多信息,我能想到的最好方法是在数据扩展中包含“附件 1”、“附件 2”等字段,并用位置填充这些字段,然后将位置作为变量包含在内在附件中。

    例如 %%=AttachFile("作品集",[附件 1])=%%

    然后只使用 IF Not EMPTY() 等条件来决定应该执行哪些函数。

    通过这种方式,您可以在每个收件人之间动态编辑位置以及调用 AttachFile 的次数。这有点凌乱和麻烦,但再次没有更多信息,这是我能做的最好的。

    【讨论】:

      【解决方案3】:

      你怎么知道附件的数量?这是已知的预发送还是直到发送时间?这是触发发送还是用户启动?

      根据这些答案,您可以通过多种方式实现这一目标。

      我将探索的主要解决方案路径是执行某种 LookupRows() 或 LookupOrderedRows() 来检索要附加的文件,然后遍历这些行并附加文件。另外,需要注意的是 AttachFile() 函数需要在 inline-AMP Script 中执行,%%=AttachFile()=%%,而不是在 AMP 代码块中,%%[ ...... ]%%。

      因此您的代码可能类似于以下内容(我包含了托管在外部站点、ET FTP 和 Portfolio 上的文件示例):

      %%[ VAR @sub, @fileDe, @files, @file, @fileUrl, @fileName, @fileExternalKey
      
          SET @sub = [_subscriberkey]
          SET @fileDE = "Name Data Extension holding attachment filename/url"
      
          /*LookupRows() from DE. Assumes data extension uses SubscriberKey as the foreign key*/
          SET @files = LookupRows(@fileDe,"SubscriberKey",@sub)
      
          /*Validate files were returned*/
          IF Rowcount(@files) > 0 THEN
              FOR @i = 1 TO Rowcount(@files) DO
                  SET @file = Row(@files,@i)
      
                  /*If you are using files hosted at an external HTTP/HTTPS location*/
                  SET @fileUrl = Field(@file,"FileURL")
                  ]%%
                  %%=AttachFile("HTTP",@fileUrl)=%%
                  %%[
                  /*If you are using files hosted in the Import folder of the ExactTarget FTP*/
                  SET @fileName = Field(@file,"FileName")
                  ]%%
                  %%=AttachFile("FTP",@fileName)=%%
                  %%[
                  /*If you are using files hosted in the ExactTarget Portfolio*/
                  SET @fileName = Field(@file,"PortfolioFileExternalKey")
                  ]%%
                  %%=AttachFile("Portfolio",@fileExternalKey)=%%
                  %%[
              NEXT @i
          ELSE
              /*No records returned for @files*/
          ENDIF
      ]%%
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多