0

I'm using the following AMPscript to fire a triggered send from a landingpage, but nothing happens – there's actually no Error message when executing the script.

Any ideas?

VAR @emailaddr, @ts, @tsDef, @ts_subkey, @ts_sub
SET @emailaddr = "[email protected]"
SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SET @ts_subkey = @emailaddr 

SetObjectProperty(@tsDef, "CustomerKey", 187)
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)

SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "EmailAddress", @emailaddr)
SetObjectProperty(@ts_sub, "SubscriberKey", @emailaddr)

AddObjectArrayItem(@ts, "Subscribers", @ts_sub)

1 Answer 1

0

You are missing InvokeCreate Function. You can look ampscript API function to know more.

Below is the updated code:

%%[
VAR @emailaddr, @ts, @tsDef, @ts_subkey, @ts_sub
SET @emailaddr = "[email protected]"
SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SET @ts_subkey = @emailaddr 

SetObjectProperty(@tsDef, "CustomerKey", 187)
SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)

SET @ts_sub = CreateObject("Subscriber")
SetObjectProperty(@ts_sub, "EmailAddress", @emailaddr)
SetObjectProperty(@ts_sub, "SubscriberKey", @emailaddr)

AddObjectArrayItem(@ts, "Subscribers", @ts_sub)

SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)

]%%
%%=v(@ts_statusCode)=%%

Output: OK -> email sent

Output: error -> email not sent

3
  • Thanks. Just tried it, but the output %%=v(@ts_statusCode)=%% still keeps empty
    – Michael H
    Commented Jun 18, 2017 at 7:33
  • Found the issue, I used this block along with another DEInsert function within %%[ ]%% block. Now I set it in an own one and it was working. Can anyone explain me way it won't work when putting it in the same %%[ ] %% ?
    – Michael H
    Commented Jun 18, 2017 at 7:39
  • %%==%% is used to print the output of the function, it accepts the static values. this can also be written inside the HTML tags, whereas %%[]%% block is used to write the ampscript logics combined with functions. If you want to output the function inside the %%[]%% block then use output() function. for output function refer help.marketingcloud.com/en/documentation/ampscript/…
    – Abhishek
    Commented Jun 19, 2017 at 0:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .