# Outlook Web Access (Exchange 5.5) # # @Requires: 1.1 beta3 # @Version: 1.1.2 # german texts (with MrPostman 1.2.2+) # @Version: 1.1.1 # corrected parsing of addresses: ; replaced with , # @Version: 1.1 # read appointments # ... sub getInfo local(info) info.name = "outlookWA" info.authors[0] = "Martin Vlcek " info.version = "1.1.2" info.updateService = "" info.documentationLink = "/en/outlookwa/index.html" info.options["extension"].order = 1 info.options["extension"].value = "@server.com" info.options["extension"].label = "Mail Extensions" info.options["extension"].description = "Extensions (include the @!) separated by ','" info.options["isHttp"].order = 2 info.options["isHttp"].value = false info.options["isHttp"].label = "Use HTTP" info.options["isHttp"].description = "Use HTTP rather than HTTPS for sign on" info.options["host"].order = 3 info.options["host"].value = "your.server.com" info.options["host"].label = "Server Name" info.options["host"].description = "Set to the server name, which you would access for the mail extension" info.options["loginlink"].order = 4 info.options["loginlink"].value = "/exchange/logonfrm.asp?isnewwindow=0&mailbox=" info.options["loginlink"].label = "Login Link" info.options["loginlink"].description = "Only change in special cases! The user name is appended during login." info.options["locale"].order = 5 info.options["locale"].value = "de" info.options["locale"].label = "Locale" info.options["locale"].description = "Locale, e.g. 'de' (German), 'en' (English)" info.options["dateFormat"].order = 6 info.options["dateFormat"].value = "dd.MM.yyyy HH:mm" info.options["dateFormat"].label = "Date Format" info.options["dateFormat"].description = "Format of the date in Java SimpleDateFormat syntax" #--- german texts info.options["extension"].de.label = "E-Mail-Endungen" info.options["extension"].de.description = "E-Mail-Endungen (mit @) getrennt durch ','" info.options["isHttp"].de.label = "HTTP verwenden" info.options["isHttp"].de.description = "HTTP anstatt HTTPS verwenden" info.options["host"].de.label = "Server-Name" info.options["host"].de.description = "Der Name des Servers, der die E-Mails mittels OWA bereitstellt" info.options["loginlink"].de.label = "Anmelde-Link" info.options["loginlink"].de.description = "Nur in Sonderfällen zu ändern! Der Benutzername wird beim Anmelden angehängt" info.options["locale"].de.label = "Sprache" info.options["locale"].de.description = "Sprache der OWA-Installation, z.B. 'de' (Deutsch), 'en' (Sprache)" info.options["dateFormat"].de.label = "Datumsformat" info.options["dateFormat"].de.description = "Format des Datums in Java SimpleDateFormat-Syntax (siehe Hilfe)" return info end sub getExtensions # more fault tolerant in regard to separators than specified in description return split(info.options["extension"].value,"[\s,;]+") end sub login(username,password) local(found,domain,mailext,pattern_mainframe) #debug(true) found,user,domain,mailext = match(username,"(.+)\.([^.]*)(@.*)") failif(!found,"Invalid user name - see help!") addcredentials(iif(domain=="",user,domain&"/"&user),password) setbaseurl(iif(info.options["isHttp"].value,"http://","https://") & info.options["host"].value) size.locale = info.options["locale"].value size.unit = map("B",1,"KB",1024,"MB",1024*1024,"GB",1024*1024*1024) date.locale = info.options["locale"].value date.format = info.options["dateFormat"].value url = info.options["loginlink"].value & user status,page = get(url) if (status==401) #-- workaround: retry, as first try gives authorization failure here for me status,page = get(url) end failif(status!=200,"Error retrieving main page!") pattern_mainframe = "\"([^\"]*main_fr.asp[^\"]*)\"" found,url = match(page,pattern_mainframe) status,page = get(url) failif(status!=200,"Error retrieving main frame of main page") return page end sub loginForReceive(username,password) local(ok,url,status,page,found,pattern_msgframe,pattern_msgline) page = login(username,password) pattern_msgframe = "\"([^\"]*messages.asp\?obj=([^&\"]+)&[^\"]*)\"" found,url,inboxid=match(page,pattern_msgframe) status,page = get(url) failif(status!=200,"Error retrieving message list frame!") pattern_msgline = "openNewWindow\(\"([^\"]*frmRoot.asp\?index=(\d+)&obj=([^&]+)&command=open)\".*?>(\d+)\s*(B|KB|MB|GB)<" numfound,msgs[].link,msgs[].index,msgs[].id,msgs[].size.value,msgs[].size.unit = matchall(page,pattern_msgline) return true end sub receive(msg) local(found,status,page,from,to,cc,bcc,subj,date,attachpat) status,page = get(msg.link) msg.mimetype = "text/html" found,link = match(page,"(.*?)",true) msg.from = convertAddrOutlook2Mail(from) found,to = match(page,"(.*?)",true) msg.to = convertAddrOutlook2Mail(to) found,cc = match(page,"(.*?)",true) msg.cc = convertAddrOutlook2Mail(cc) found,bcc = match(page,"(.*?)",true) msg.bcc = convertAddrOutlook2Mail(bcc) found,date = match(page,"(.*?)",true) msg.date = trim(replaceall(date,"<.*?>| ",""),true) found,subj = match(page,"(.*?)",true) msg.subject = trim(replaceall(subj,"<.*?>| ",""),true) found,msg.text = match(page,".*?]*?>(.*).*?",true) msg.text = "" & msg.text & "" attachpat = "]*?TITLE=\"([^\"]+)\"" found,msg.attachments[].link,msg.attachments[].text = matchall(msg.text,attachpat) msg.text = replaceall(msg.text,attachpat,"") return msg end sub receiveDate(msg,link) local(rowpat,found,from,date,to,cc,subject) #-- not extensively tested yet, only reads the most important information: status,page = get(link) found,from = match(page,"(.*?)",true) msg.from = convertAddrOutlook2Mail(from) found,to = match(page,"(.*?)",true) msg.to = convertAddrOutlook2Mail(to) found,cc = match(page,"(.*?)",true) msg.cc = convertAddrOutlook2Mail(cc) found,bcc = match(page,"(.*?)",true) msg.bcc = convertAddrOutlook2Mail(bcc) found,date = match(page,"(.*?)",true) msg.date = trim(replaceall(date,"<.*?>| ",""),true) found,subj = match(page,"(.*?)",true) msg.subject = trim(replaceall(subj,"<.*?>| ",""),true) #--- additional fields for appointments found,loc = match(page,"(.*?)",true) loc = trim(replaceall(loc,"<.*?>| ",""),true) found,when = match(page,"(.*?)",true) when = trim(replaceall(when,"<.*?>| ",""),true) found,status= match(page,"(.*?)",true) status = trim(replaceall(status,"<.*?>| ",""),true) #--- message text found,msg.text = match(page,".*?]*?>(.*).*?",true) #--- add additional fields to message text if (when != "") msg.text = "When: " & when & "
\n" & msg.text end if (loc != "") msg.text = "Location: " & loc & "
\n" & msg.text end if (status != "") msg.text = "Status: " & status & "
\n" & msg.text end msg.text = "" & msg.text & "" return msg end sub loginForSend(username,password) local(page,found) page = login(username,password) found,newlink = match(page,"openNewWindow\(\"([^\"]*frmroot.asp[^\"]*command=new[^\"]*store=)\"") newlink = newlink & "0" return true end sub send(msg) local(status,page,found,id,attachment,params,uparams) setbaseurl(geturl(newlink)) status,page = get(newlink) found,id = match(page,"obj=(\d+)") foreach (msg.attachments,attachment) uparams["tab"] = "nobind" uparams["command"] = "send" uparams["objID"] = id uparams["obj"] = id uparams["RedirectURL"] = "Forms/IPM/NOTE/cmpAtt.ASP" status,page = upload("/exchange/exupload.dll","ffname",attachment.link,uparams) end params["to"] = replaceAll(msg.to,",",";") params["cc"] = replaceAll(msg.cc,",",";") params["bcc"] = replaceAll(msg.bcc,",",";") params["subject"] = msg.subject params["message"] = msg.text params["tab"] = "message" params["command"] = "send" params["objID"] = id params["savecopy"] = "1" params["importance"]= "1" status,page = post("commands.asp",params) return (status == 200) end sub convertAddrOutlook2Mail(addr) addr = replaceall(addr,"<.*?>| |\\n|\\r","") addr = replaceall(addr,"\s*(\b[^;\[]*?\b)\s*(?:\[SMTP:([^\]]+)\])?\s*(\Z|;)","\"$1\" <$2>, ") addr = replaceall(addr,"<>|,\s*(\"\")?\s*\Z","") return trim(addr,true) end sub delete(msgs) warning("Deleting of messages not supported!") return false end sub logout #-- do nothing return true end