Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SMTPExtras1 As SMTPExtras
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
SMTPExtras1.Initialize("smtp.somedomain.com", Port, "Username", "Password", "EventName") '<-- Event Name in this case - "SMTPExtras1"
SMTPExtras1.UseSSL = False ' Gmail requires SSL.
End If
SendNewScript
End Sub
Sub SendNewScript
ProgressDialogShow("Preparing your request")
File.Copy(Path1, GlobFileName, Starter.shared, GlobFileName) 'Put the file in a shared space ready for attaching
Dim SendTo As String = Starter.kvs.Get("FaveMail")
Dim SendBCC As String = Starter.kvs.Get("eMail")
Dim SendBody As String = "Please prepare this script and contact me once it is complete and ready for delivery or collection."&CRLF&CRLF&"I do understand that I can only receive my medication on presentation of the original script"&CRLF&CRLF&CRLF&CRLF&Starter.kvs.get("UserName")
Dim SendSub As String = "New Script for: "&Starter.kvs.get("UserName")&" - "&Starter.kvs.get("IdNumber")
'''' SendEmail (SendTo, SendBody, SendSub, File.Combine(Starter.shared, GlobFileName ))
SMTPExtras1.AuthMethod=SMTPExtras1.AUTH_LOGIN
SMTPExtras1.To.Add(SendTo)
' SMTPExtras1.BCC.Add(SendBCC)
SMTPExtras1.Subject = SendSub
SMTPExtras1.Body = SendBody
SMTPExtras1.AddAttachment(Starter.shared, GlobFileName)
SMTPExtras1.AddHeader("Who","PAS APP at "&DateTime.Now)
SMTPExtras1.AddHeader("Sender Id:", "Value: "&Starter.kvs.get("IdNumber"))
' if you uncomment the next line then you'll see that the MessageSent(Success As Boolean) event is raised instead of the MessageSent2(Success As Boolean, Tag As Object) event
SMTPExtras1.Tag=Starter.kvs.Get("FaveMail")
SMTPExtras1.Send
LogColor("Fav eMail: "&Starter.kvs.Get("FaveMail"),Colors.Magenta)
LogColor("CC eMail: "&Starter.kvs.Get("eMail"),Colors.Magenta)
SMTPExtras1.To.Add(SendBCC)
SMTPExtras1.Subject = SendSub
SMTPExtras1.Body = SendBody
SMTPExtras1.AddAttachment(Starter.shared, GlobFileName)
SMTPExtras1.AddHeader("Who","PAS APP at "&DateTime.Now)
SMTPExtras1.AddHeader("Sender Id:", "Value: "&Starter.kvs.get("IdNumber"))
' if you uncomment the next line then you'll see that the MessageSent(Success As Boolean) event is raised instead of the MessageSent2(Success As Boolean, Tag As Object) event
SMTPExtras1.Tag=Starter.kvs.Get("eMail")
SMTPExtras1.Send
scriptsend = False
End Sub
Sub SMTPExtras1_MessageSent(Success As Boolean)
' the event MessageSent(Success As Boolean) is identical to the same event in the default SMTP object
Log("SMTPExtras1_MessageSent "&Success)
If Success Then
ProgressDialogHide
ToastMessageShow("Your Prescription was Sent Successfully", True)
Else
ProgressDialogHide
ToastMessageShow("Error Sending Prescription", True)
Log(LastException.Message)
End If
' Button1.Enabled=True
End Sub
Sub SMTPExtras1_MessageSent2(Success As Boolean, Tag As Object)
' MessageSent2(Success As Boolean, Tag As Object) is a new event introduced in SMTPExtras
' if you set the SMTPExtras Tag property to a value then SMTPEXtras will raise the event MessageSent2(Success As Boolean, Tag As Object)
' if you do not set the SMTPExtras Tag property, or you set it to Null, then SMTPExtras will instead raise the event MessageSent(Success As Boolean)
Log("SMTPExtras1_MessageSent2 "&Success&", "&Tag)
If Success Then
ProgressDialogHide
ToastMessageShow("Message sent successfully to "&Tag, True)
Else
ProgressDialogHide
ToastMessageShow("Error sending message to "&Tag, True)
Log(LastException.Message)
End If
End Sub