Page 1 of 1

sending attachement pdf or jpg with outlook email

Posted: Mon Sep 29, 2014 7:51 pm
by sphere
Hello,

in my extensive search here and on the web i found very little options to send an email with an attachment like pdf or jpg.
I read one who works with thunderbird and one from 2011 which can add a pdf but then for iOS.

Sure there most be somehow a way to send an email via outlook with an attachement even if the user only has to push Send on the message?
revmail and revmailunicode only seems to be able to send text as an attachment. Also noticed that LiveMail from microsoft not opens with this command.

Maybe anyone who knows something or has a link to an example?

Thanks very much.

Re: sending attachement pdf or jpg with outlook email

Posted: Tue Sep 30, 2014 2:45 pm
by sphere
Ok i found the SMTP library demo and it seems to work well.
I will try to implement this.

anybody know if the script part under the library button is also needed or just the main big script?

Thanks for any help!

Re: sending attachement pdf or jpg with outlook email

Posted: Thu Oct 02, 2014 9:38 pm
by sphere
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:

Code: Select all

disable me
    connectToServer 
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.