This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 192
/
sample_email.py
112 lines (101 loc) · 6.11 KB
/
sample_email.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import ET_Client
try:
debug = False
stubObj = ET_Client.ET_Client(False, debug)
# Retrieve All Email with GetMoreResults
print('>>> Retrieve All Email with GetMoreResults')
getHTMLBody = ET_Client.ET_Email()
getHTMLBody.auth_stub = stubObj
getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
getResponse = getHTMLBody.get()
print('Retrieve Status: ' + str(getResponse.status))
print('Code: ' + str(getResponse.code))
print('Message: ' + str(getResponse.message))
print('MoreResults: ' + str(getResponse.more_results))
print('Results Length: ' + str(len(getResponse.results)))
#print 'Results: ' + str(getResponse.results)
while getResponse.more_results:
print('>>> Continue Retrieve All Email with GetMoreResults')
getResponse = getHTMLBody.getMoreResults()
print('Retrieve Status: ' + str(getResponse.status))
print('Code: ' + str(getResponse.code))
print('Message: ' + str(getResponse.message))
print('MoreResults: ' + str(getResponse.more_results))
print('RequestID: ' + str(getResponse.request_id))
print('Results Length: ' + str(len(getResponse.results)))
NameOfTestEmail = "PythonSDKEmail"
# Create Email
print('>>> Create Email')
postHTMLBody = ET_Client.ET_Email()
postHTMLBody.auth_stub = stubObj
postHTMLBody.props = {"CustomerKey" : NameOfTestEmail, "Name":NameOfTestEmail, "Subject" : "Created Using the PythonSDK", "HTMLBody": "<b>Some HTML Goes here</b>"}
postResponse = postHTMLBody.post()
print('Post Status: ' + str(postResponse.status))
print('Code: ' + str(postResponse.code))
print('Message: ' + str(postResponse.message))
print('Result Count: ' + str(len(postResponse.results)))
print('Results: ' + str(postResponse.results))
# Retrieve newly created Email
print('>>> Retrieve newly created Email')
getHTMLBody = ET_Client.ET_Email()
getHTMLBody.auth_stub = stubObj
getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
getHTMLBody.search_filter = {'Property' : 'CustomerKey','SimpleOperator' : 'equals','Value' : NameOfTestEmail}
getResponse = getHTMLBody.get()
print('Retrieve Status: ' + str(getResponse.status))
print('Code: ' + str(getResponse.code))
print('Message: ' + str(getResponse.message))
print('MoreResults: ' + str(getResponse.more_results))
print('Results Length: ' + str(len(getResponse.results)))
print('Results: ' + str(getResponse.results))
# Update Email
print('>>> Update Email')
patchHTMLBody = ET_Client.ET_Email()
patchHTMLBody.auth_stub = stubObj
patchHTMLBody.props = {"CustomerKey" : NameOfTestEmail, "Name":NameOfTestEmail, "HTMLBody": "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
patchResponse = patchHTMLBody.patch()
print('Patch Status: ' + str(patchResponse.status))
print('Code: ' + str(patchResponse.code))
print('Message: ' + str(patchResponse.message))
print('Result Count: ' + str(len(patchResponse.results)))
print('Results: ' + str(patchResponse.results))
# Retrieve updated Email
print('>>> Retrieve updated Email')
getHTMLBody = ET_Client.ET_Email()
getHTMLBody.auth_stub = stubObj
getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
getHTMLBody.search_filter = {'Property' : 'CustomerKey','SimpleOperator' : 'equals','Value' : NameOfTestEmail}
getResponse = getHTMLBody.get()
print('Retrieve Status: ' + str(getResponse.status))
print('Code: ' + str(getResponse.code))
print('Message: ' + str(getResponse.message))
print('MoreResults: ' + str(getResponse.more_results))
print('Results Length: ' + str(len(getResponse.results)))
print('Results: ' + str(getResponse.results))
# Delete Email
print('>>> Delete Email')
deleteHTMLBody = ET_Client.ET_Email()
deleteHTMLBody.auth_stub = stubObj
deleteHTMLBody.props = {"CustomerKey" : NameOfTestEmail, "Name":NameOfTestEmail, "HTMLBody": "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
deleteResponse = deleteHTMLBody.delete()
print('Delete Status: ' + str(deleteResponse.status))
print('Code: ' + str(deleteResponse.code))
print('Message: ' + str(deleteResponse.message))
print('Result Count: ' + str(len(deleteResponse.results)))
print('Results: ' + str(deleteResponse.results))
# Retrieve Email to confirm deletion
print('>>> Retrieve Email to confirm deletion')
getHTMLBody = ET_Client.ET_Email()
getHTMLBody.auth_stub = stubObj
getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
getHTMLBody.search_filter = {'Property' : 'CustomerKey','SimpleOperator' : 'equals','Value' : NameOfTestEmail}
getResponse = getHTMLBody.get()
print('Retrieve Status: ' + str(getResponse.status))
print('Code: ' + str(getResponse.code))
print('Message: ' + str(getResponse.message))
print('MoreResults: ' + str(getResponse.more_results))
print('Results Length: ' + str(len(getResponse.results)))
print('Results: ' + str(getResponse.results))
except Exception as e:
print('Caught exception: ' + e.message)
print(e)