It's getting the progress ID at:
and passing it toProgressId.i = MailProgress(OutgoingMailId.i)
Debug GetLastErrorString(ProgressId.i)
Code: Select all
Procedure.s GetLastErrorString(Error.i = #False)Anyone feel bloody minded enough to tell me where the mistake might be? I will sacrifice a politician on a spit for you.
Code: Select all
Procedure Address_EmailAddressSend()
Protected Message.s
MailToUser.s = GetGadgetText(#Gadget_Addressemail_sentto)
MailToSubject.s = GetGadgetText(#Gadget_Addressemail_subject)
MailToBody.s = GetGadgetText(#Gadget_Addressemail_message)
; Get email details from json file
If PGM::Get("smtp human name") And
PGM::Get("smtp server name") And
Val(PGM::Get("smtp server port")) And
PGM::Get("smtp user name") And
PGM::Get("smtp server password") And
PGM::Get("smtp email address")
If MailToUser.s And MailToSubject.s And MailToBody.s
OutgoingMailId.i = CreateMail(#PB_Any, PGM::Get("smtp email address"), MailToSubject.s)
If OutgoingMailId.i <> #False
SetMailAttribute(OutgoingMailId.i, #PB_Mail_XMailer, "Stormy")
SetMailBody(OutgoingMailId.i, MailToBody.s)
AddMailRecipient(OutgoingMailId.i, MailToUser.s, #PB_Mail_To)
; PB 6.20 beta 1
If SendMail(OutgoingMailId.i, PGM::Get("smtp server name"), Val(PGM::Get("smtp server port")), #PB_Mail_UseSSL | #PB_Mail_UseSMTPS, PGM::Get("smtp user name"), PGM::Get("smtp server password")) <> #False
; PB 6.10, 6.12
; If SendMail(OutgoingMailId.i, PGM::Get("smtp server name"), Val(PGM::Get("smtp server port")), #PB_Mail_Asynchronous | #PB_Mail_UseSSL, PGM::Get("smtp user name"), PGM::Get("smtp server password")) <> #False
Repeat
ProgressId.i = MailProgress(OutgoingMailId.i)
Debug GetLastErrorString(ProgressId.i)
If ProgressId.i = #PB_Mail_Connected
MailMessage("Connected to the " + PGM::Get("smtp server name") + " email server", "Info")
ElseIf ProgressId.i = #PB_Mail_Error
MailMessage("Error connecting and sending message to " + PGM::Get("smtp server name"), "Error")
MailMessage("The email message packet has created some sort of error", "Error")
ElseIf ProgressId.i = #PB_Mail_Finished
MailMessage("The email message packet has been correctly sent", "Info")
Else
MailMessage("Sent " + Str(ProgressId.i) + " Bytes", "Info")
EndIf
Delay(300)
Until ProgressId.i = #PB_Mail_Finished Or ProgressId.i = #PB_Mail_Error
Else
MailMessage("The mail packet could not be sent", "Error")
Debug GetLastErrorString(ProgressId.i)
EndIf
Else
MailMessage("Could not create the outgoing email message", "Error")
EndIf
Else
MailMessage("One or more of the recipient's details are empty", "Warn")
EndIf
Else
MailMessage("One or more of the email server details are empty!", "Warn")
MessageRequester("Server Details Error", Message.s + #CRLF$ + #CRLF$ + "Correct this before trying to send an email.", #MB_ICONERROR)
EndIf
EndProcedure
Code: Select all
Procedure.s GetLastErrorString(Error.i = #False)
If Not Error.i
Error.i = GetLastError_()
EndIf
Protected Buffer.i, ResultString.s
If FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER | #FORMAT_MESSAGE_FROM_SYSTEM, 0, Error.i, 0, @Buffer, 0, 0)
ResultString.s = PeekS(Buffer)
LocalFree_(Buffer)
ProcedureReturn ResultString.s
EndIf
EndProcedure 
