Hi,
in my script for the SEND button i added a whole bunch of code form the SMTP_library_demo.
The library demo is working ok on itself but i like to embed it. A few things i know does not have to be asked from the user.
so no authentication is needed, just the known email server adress. thats all and it works.
But embedding it don't work as i thoughd meybe someone can help or can point me to some help.
Is it neccessary to embed the whole stack of the library demo?
Between on mouseUp and end mouseUp i added this (because it the originall this was also between and the rest outside the mousies:
and after the end mouseUp this:
Code: Select all
-- main connection handler for sending email with attachement
-- mail server adress of UL is smtp-relay.blabla.com
on connectToServer
-- start using SMTP library if necessary
#if the stacksinuse contains "sSMTPlibrary" is false then
#start using stack "sSMTPlibrary"
#end if
#put the hilite of btn "Debug" into debugOn
#put empty into fld "Log"
-- check for incomplete SMTP server & email data
if checkData("SMTP") = false then
enable me
exit connectToServer
end if
-- specify the fields to be used for logging
-- these commands must get "the long name" of the relevant fields
#if the hilite of btn "Debug" then
#put "verbose" into transcriptSet
#else
#put "plain" into transcriptSet
#end if
#sSMTPsetTranscriptField the long name of fld "Log", transcriptSet
#sSMTPsetStatusField the long name of fld "Status"
local tServerAddress
put smtp-relay.blabla.com into tServerAddress
#enable btn "Stop"
#sSMTPconnectToServer fld "Server", "sendEmails", the hilite of btn "Auth", fld "User", fld "Pass"
sSMTPconnectToServer tServerAddress, "sendEmails"
end connectToServer
-- callback handler after connection
-- if OK, sends the email
-- otherwise, reports the error and exits
--
on sendEmails pState
if pState <> "OK" then
answer "Connection error: " & pState
sSMTPdisconnectFromServer
disable btn "Stop"
enable me
else
put the hilite of btn "HTML" into tUseHTML
put assembleBody(tUseHTML) into tBody
put sSMTPbuildEmailText(fld "From", tReceiver, "bla bla bla " & tNameD, \
tBody, tAttachment, tUseHTML) into tBody
sSMTPsendMessage fld "From", tReceiver, "bla bla bla " & tNameD,\
tBody, "messageSent", tAttachment
end if
end sendEmails
-- utility function to find the correct format of text to include as the body of the email
--
#function assembleBody pUseHTML
#if pUseHTML then
-- see if the text is formatted, or whether html has been typed in
#if fld "Body" contains "<html>" then
#return the text of fld "Body"
#else
#return the htmltext of fld "Body"
#end if
#else
#return the text of fld "Body"
#end if
#end assembleBody
-- callback handler after sending email
-- if not OK, reports the error
-- disconnects from server no matter what
--
on messageSent pState
if pState <> "OK" then answer "Mail sending error: " & pState
sSMTPdisconnectFromServer
#disable btn "Stop"
enable me
end messageSent
-- function to check that all relevant preferences have been entered
--
function checkData
put empty into badData
#if fld "Server" is empty then put tab & "SMTP server" & cr into badData
#if the hilite of btn "Auth" then
#if fld "User" is empty then put tab & "User name" & cr after badData
#if fld "Pass" is empty then put tab & "Password" & cr after badData
#end if
#if fld "To" is empty then put tab & "To" & cr into badData
if fld "From" is empty then put tab & "From" & cr into badData
#if fld "Subject" is empty then put tab & "Subject" & cr into badData
if badData is not empty then
answer error "The following data is missing or invalid:" & cr & badData
return false
else
return true
end if
end checkData
i # out some lines because in my opinion are not needed, because authentication is not needed and some buttons i don't need, i only need the send button.
and some locals are also in the whole script.
does anyone have a clue why this does not work, and the original does. its almost a one on one copy except for the server name.
am i forgetting to add something specail to the script from the button or to the stack?
thanks for any help on this.