# Outlook Web Access sub getInfo local(info) info.name = "whatever" info.authors[0] = "Martin Vlcek " info.version = "0.1" info.updateService = "" info.documentationLink = "" info.options["link"].value = "url/to/your/login.cgi" info.options["link"].label = "LoginLink" info.options["link"].description = "The HTML page with the login form" info.options["extensions"].value = "@yourdomain" info.options["extensions"].label = "Extensions" info.options["extensions"].description = "Extensions (including @) separated by ','" return info end sub getExtensions return split(info.options["extensions"].value,",") end sub login(username,password) local(found,extension,status,page,t,params) debug(true) found,user,domain = match(username,"\A(.*)@(.*)\Z") template = "YourTemplateName" #--- after setting the base url relative links will be done correctly: setbaseurl(info.options["link"].value) #--- set some basic settings to allow MrPostman do some conversions, ... size.locale = "en" size.unit = map("B",1,"KB",1024,"MB",1024*1024,"GB",1024*1024*1024) date.locale = "en" date.format = "EEE, MMM d, yyyy HH:mm:ss Z" #--- let's log in: params["initial_login"] = "1" params["login_state"] = "1" params["t"] = template params["domain"] = domain params["username"] = user params["password"] = password params["cookie"] = "No" status,page = get(info.options["link"].value,params) found,logoutlink = match(page,"href=\"([^\"]*logout.cgi[^\"]*)\"") found,sid = match(page,"name=\"sid\" value=\"([^\"]*)\"") return page end sub loginForReceive(username,password) local(page,msgpat,numfound) page = login(username,password) #--- we are at the inbox page: get the messages msgpat = "href=\"([^\"]*msgtrack_id=(\d+);[^\"]*)\".*?>([\d\.]+)\s+(.?B)<" numfound,msgs[].link,msgs[].id,msgs[].size.value,msgs[].size.unit = matchall(page,msgpat) info("Found " & numfound & " messages.") return true end sub receive(msg) info("Getting message " & msg.id & "...") status,page = get(msg.link) msg.mimetype = "text/plain" found,msg.from = match(page,">From:<.*?>([^<]*)") found,msg.to = match(page,">To:<.*?([^<]*)<") found,msg.cc = match(page,">CC:<.*?([^<]*)<") found,msg.date = match(page,">Date:<.*?([^<]*)<") found,msg.subject = match(page,">Subject:<.*?([^<]*)<") found,msg.text = match(page,"
(.*)
") if (!found) #--- HTML message found,msg.text = match(page,"id=\"mailbody\">(.*?)\s*\s*") msg.mimetype = "text/html" end attachpat = "href=\"([^\"]*do=messages-print_attach[^\"]*)\"[^>]*>([^<]*) 0,"Message " & msg.id & " has " & numfound & " attachments (" & string(msg.attachments[].text,", ") & ")") return msg end sub delete(msgs) local(params,i,status,page) params["sid"] = sid params["t"] = template params["page"] = "home.htm" params["sb"] = "msgs_sent" params["so"] = "desc" params["mh"] = "15" params["nh"] = "1" i = 0 while (i < size(msgs)) params["msgtrack_id#"&i] = msgs[i].id i = i+1 end params["do=messages-delete"] = "" status,page = post("webmail.cgi",params) return true end sub loginForSend(username,password) # not implemented return false end sub send(msg) # not implemented return false end sub logout get(trim(logoutlink)) end