-
Notifications
You must be signed in to change notification settings - Fork 1
/
SendMail_Simpl#_v1.usp
140 lines (92 loc) · 3.16 KB
/
SendMail_Simpl#_v1.usp
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#SYMBOL_NAME "SendMail_Simpl#_v1"
#IncludePath "C:\userSimpl#"
#USER_SIMPLSHARP_LIBRARY "MailServer"
#HELP_BEGIN
The module has preconfigred email servers or you can specify your own that is not in the list.
Custom_Mail_Server:
*Optional Custom Main Server
Custom_Mail_Server_Port:
*Optional custom mail server port
User_Name: Your email user name
Password: your account password
From: A friendly name. Example : Home Processor
#_Of_Attachments:
Optional. Specifies the number of attachments to be sent. Zero (0) specifies
that there are no attachments.
Attachment_Path$:
Optional. An empty string indicates that no attachments are to be sent. Specifies
the files to be attached. Multiple filenames may be specified, delimited
by ';'. Max field length is 65534.
Send:(mandatory fields)
Sends the message via the chosen client.
ReceiverAddress : who you are sending to
Subject: Subject. Example: Front Door Activity
Message: Messsage to send. Example: There is someone at the front door
#HELP_END
string_parameter Mail_Server[100];
string_parameter Custom_Mail_Server[50];
integer_parameter Custom_Mail_Server_Port;
string_parameter User_Name[50];
string_parameter Password[50];
string_parameter From[50];
Digital_Input _Skip_,_Skip_,_Skip_,_Skip_,_Skip_,_Skip_,Send;
String_Input RecieverAddress[50];
String_input Subject[100];
String_input Message[500];
String_input _Skip_,_Skip_,Attachment_Path$[5000];
analog_input #_Of_Attachments;
Digital_Output _Skip_,_Skip_,_Skip_,_Skip_,_Skip_,_Skip_,MailSent,MailSendError;
String_Output _Skip_,SendResult$;
SimpleMailServer mail;
string at[5500];
#BEGIN_PARAMETER_PROPERTIES Mail_Server
propValidUnits = unitString;
propList = { "1" , "Hotmail" } , { "2" , "Gmail" } , { "3" , "Yahoo" }, { "4" , "Custom" } ;
#END_PARAMETER_PROPERTIES
Push Send
{
mail.Reciever = RecieverAddress;
mail.Message = Message;
mail.Subject = Subject;
mail.Attachment = Attachment_Path$;
mail.Number_Of_Attachments = #_Of_Attachments;
mail.Send();
}
Callback function ReturnMail(string msg)
{
SendResult$ = msg;
if (msg = "SMTP_OK")
{Pulse (200,MailSent);}
else
{
Pulse (200,MailSendError);
}
}
Function Main()
{
waitforinitializationcomplete();
registerdelegate (mail, SendStatus, ReturnMail);
if(Mail_Server = "1")
{
mail.Server = "smtp.live.com";
mail.Port = 587;
}
if(Mail_Server = "2")
{
mail.Server = "smtp.gmail.com";
mail.Port = 465;
}
if(Mail_Server = "3")
{
mail.Server = "smtp.mail.yahoo.com";
mail.Port = 465;
}
if(Mail_Server = "4")
{
mail.Server = Custom_Mail_Server;
mail.Port = Custom_Mail_Server_Port;
}
mail.UserName = User_Name;
mail.Password = Password;
mail.From = From;
}