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 = "test@testmail.com"
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)
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 = "test@testmail.com"
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

  • Thanks. Just tried it, but the output %%=v(@ts_statusCode)=%% still keeps empty – Michael H Jun 18 '17 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 Jun 18 '17 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 Jun 19 '17 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.