1VAR @sub, @attr, @list, @statusCode, @statusMsg, @subKey, @errorCode
2
3//Create a subscriber object using the provided email address
4SET @subKey = RequestParameter("EmailAddress")
5SET @sub = CreateObject("Subscriber")
6
7//Set the email address as the subscriber key value for the contact
8IF NOT EMPTY(@subKey) THEN SetObjectProperty(@sub, "SubscriberKey", @subKey)
9ENDIF
10SetObjectProperty(@sub, "EmailAddress", RequestParameter("EmailAddress"))
11
12//Set the first name value for the contact using the value from the request
13IF NOT IsNull(RequestParameter("First Name")) THEN
14 SET @attr = CreateObject("Attribute")
15 SetObjectProperty(@attr, "Name", "First Name")
16 SetObjectProperty(@attr, "Value", RequestParameter("First Name"))
17 AddObjectArrayItem(@sub, "Attributes", @attr)
18ENDIF
19
20//Set the middle initial value for the contact using the value from the request
21IF NOT IsNull(RequestParameter("Middle Initial")) THEN
22 SET @attr = CreateObject("Attribute")
23 SetObjectProperty(@attr, "Name", "Middle Initial")
24 SetObjectProperty(@attr, "Value", RequestParameter("Middle Initial"))
25 AddObjectArrayItem(@sub, "Attributes", @attr)
26ENDIF
27
28//Set the last name value for the contact using the value from the request
29IF NOT IsNull(RequestParameter("Last Name")) THEN
30 SET @attr = CreateObject("Attribute")
31 SetObjectProperty(@attr, "Name", "Last Name")
32 SetObjectProperty(@attr, "Value", RequestParameter("Last Name"))
33 AddObjectArrayItem(@sub, "Attributes", @attr)
34ENDIF
35
36//Indicate the OYB account from which the triggered send originates, add to array of attributes from the request
37SET @attr = CreateObject("Attribute")
38SetObjectProperty(@attr, "Name", "ChannelMemberID")
39SetObjectProperty(@attr, "Value", "INSERT NUMBER HERE")
40AddObjectArrayItem(@sub, "Attributes", @attr)
41
42//Add a timestamp value to the triggered send, add to array of attributes from the request
43SET @attr = CreateObject("Attribute")
44SetObjectProperty(@attr, "Name", "date_added")
45SetObjectProperty(@attr, "Value", Format(Now(),"MM/dd/yyyy"))
46AddObjectArrayItem(@sub, "Attributes", @attr)
47
48//Indicate the subscriber list used as part of the triggered send
49SET @list = CreateObject("SubscriberList")
50SetObjectProperty(@list, "Status", "Active")
51SetObjectProperty(@list, "ID", "INSERT NUMBER HERE")
52SetObjectProperty(@list, "Action", "create")
53AddObjectArrayItem(@sub, "Lists", @list)
54
55//Check the status of the send and raise an error if something goes wrong
56SET @statusCode = InvokeCreate(@sub, @statusMsg, @errorCode)
57
58IF @statusCode != "OK" THEN
59 RaiseError(@statusMsg, 0, @statusCode, @errorCode)
60
61ELSE
62
63VAR @ts, @tsDef, @ts_sub, @ts_attr, @tsctr, @ts_subkey, @ts_statusCode, @ts_statusMsg, @owner, @client
64
65//Create the triggered send and set the email address used for the send
66SET @ts = CreateObject("TriggeredSend")
67SET @tsDef = CreateObject("TriggeredSendDefinition")
68SET @ts_subkey = RequestParameter("EmailAddress")
69
70//Indicate the triggered send definition used to create the triggered send
71SetObjectProperty(@tsDef, "CustomerKey", "4466")
72SetObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
73
74//Set the contact as the recipient for the triggered send
75SET @ts_sub = CreateObject("Subscriber")
76SetObjectProperty(@ts_sub, "EmailAddress", RequestParameter("EmailAddress"))
77
78//Set the contact email address as the subscriber key
79IF NOT EMPTY(@ts_subkey) THEN
80 SetObjectProperty(@ts_sub, "SubscriberKey", @ts_subkey)
81ELSE
82 SetObjectProperty(@ts_sub, "SubscriberKey", RequestParameter("EmailAddress"))
83ENDIF
84
85//Set ownership information for the triggered send
86SET @owner = CreateObject("Owner")
87SET @client = CreateObject("ClientID")
88
89SetObjectProperty(@client, "ID", "INSERT NUMBER HERE")
90SetObjectProperty(@owner, "Client", @client)
91SetObjectProperty(@ts_sub, "Owner", @owner)
92
93AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
94SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
95
96IF @ts_statusCode != "OK" THEN
97 RaiseError(concat(@ts_statusMsg,@ts_subkey,@ts), 0, @ts_statusCode, @errorCode)
98ENDIF
99
100ENDIF