UTF-8 // // ダウンロードマクロのサンプル // // Yahooメールにログインして、メールを送信するサンプルです。 // // input[3]で指定されたフォルダにある .txtファイルを全て、メールとして送信します。 // .txtファイルは、先頭行に宛先アドレス、2行目に件名(Subject)、3行目以降に // メールの本文を記述します。 // .txtファイルのエンコードは UTF-8 である必要があります。 // // Http-Cookieはinput[3]フォルダの cookie.dat というファイルに保存されます。 // :Init { // // input[0] (未使用、ダミー値を適当に指定) // input[1] YahooのログインID // input[2] パスワード // input[3] 送信するメールを格納しているフォルダ ("E:\\My Documents\\mails", etc) // } :Start { Ex:LoadCookie: dir=input[3] file="cookie.dat"; set: str[1]="http://rd.yahoo.co.jp/toppage/e/mail/?http://mail.yahoo.co.jp/"; set: str[2]="http://www.yahoo.co.jp/"; Ex:Http-Get: url=str[1] base=str[2] O:text=str[100] O:lastUrl=str[101]; if (str[100].IndexOf{".location='/ym/Compose?YY="} > 0) { //put: value=str[101]; //end: set: str[1]=str[101]; jump: GotJumper; } // set: str[1]="http://mail.yahoo.co.jp/"; set: str[2]="http://www.yahoo.co.jp/"; Ex:Http-Get: url=str[1] base=str[2] O:text=str[100] O:lastUrl=str[101]; // //write open: dir=Dir.Desktop file="debug.txt"; //write: w=str[100]; //write close: // gosub: str[3]=sub.getLoginPostdata; set: str[1]="https://login.yahoo.co.jp/config/login?"; set: str[2]=str[101]; Ex:Http-Post: url=str[1] base=str[2] post=str[3] O:text=str[100] O:lastUrl=str[101]; // gosub: str[1]=sub.getHttpEquivRefresh; if (str[1].Length < 1) { put: value="sub.getHttpEquivRefresh Error"; write open: dir=Dir.Desktop file="YahooMailLoginError.txt"; write: w=str[100]; write close: end: } // // Here, str[1] is: http://jp.f30.mail.yahoo.co.jp/ym/login?.rand=90ltpaokqn1gr // Ex:Http-Get: url=str[1] O:text=str[100] O:lastUrl=str[101]; } :GotJumper { gosub: str[5]=sub.getComposeUrl; if (str[5].Length < 1) { write open: dir=Dir.Desktop file="YahooMailPageRefreshError.txt"; write: w=str[100]; write close: end: } put: value=str[5]; set: str[2]=str[1]; gosub: str[1]=sub.get_hostParts; //str[2]からhost部分 http://jp.f30.mail.yahoo.co.jp を取り出し set: str[1]+=str[5]; } :GetWritePage { // // str[1] : URL // str[2] : Refer // Ex:Http-Get: url=str[1] base=str[2] O:text=str[100] O:lastUrl=str[101]; gosub: str[6]=sub.getFromAddress; if (str[6].Length < 0) { write open: dir=Dir.Desktop file="YahooMailGetComposePageError.txt"; write: w=str[100]; write close: // put: value="From address NotFound"; end: } put: value=str[6]; set: strl[1]=input[3]; // file list: dir=strl[1] key="*.txt" strl.index=10 O:count=intl[1]; while (intl[1] > 0) { set: intl[2]=intl[1]; culc: intl[2]--; culc: intl[2]+=10; readBinfile: file=strl[intl[2]] O:data=binl["file"]; if (binl["file"].Length < 1) { put: value="Empty file"; put: value=strl[intl[2]]; end: } set: strl[2]=binl["file"].ToString("UTF-8"); set: strl[3]=strl[2].TopLine; set: strl[2]=strl[2].Nextline; set: strl[4]=strl[2].TopLine; set: strl[2]=strl[2].Nextline; // set: str[0]="@"; set: strl[3]=strl[3].Replace("%40"); set: strl[5]="SEND=1&SD=&SC=&CAN=&docCharset=EUC-JP&PhotoMailUser=&PhotoToolInstall=&OpenInsertPhoto=&PhotoGetStart=0"; set: strl[5]+="&SaveCopy=yes&PhotoMailInstallOrigin=&.crumb="; gosub: strl[6]=sub.get_crumb; set: strl[5]+=strl[6]; set: strl[5]+="&box=&FwdFile=&FwdMsg=&FwdSubj=&FwdInline=&OriginalFrom=&OriginalSubject=&InReplyTo=&NumAtt=0&AttData="; set: strl[5]+="&UplData=&OldAttData=&OldUplData=&FName=&ATT=&VID=&Markers=&NextMarker=0&Thumbnails=&PhotoMailWith="; set: strl[5]+="&BrowseState=&PhotoIcon=&ToolbarState=&VirusReport=&Attachments=&Background=&BGRef=&BGDesc=&BGDef=&BGFg="; set: strl[5]+="&BGFF=&BGFS=&BGSolid=&BGCustom=&PlainMsg=&PhotoFrame=&PhotoPrintAtHomeLink=&PhotoSlideShowLink="; set: strl[5]+="&PhotoPrintLink=&PhotoSaveLink=&PhotoPermCap=&PhotoPermPath=&PhotoDownloadUrl=&PhotoSaveUrl=&PhotoFlags="; set: strl[5]+="&start=compose&bmdomain=&FromAddr=&To="; set: strl[5]+=strl[3]; set: strl[5]+="&Cc=&Bcc=&Subj="; set: strl[5]+=strl[4].UrlEncode("EUC-JP"); set: strl[5]+="&Body="; set: strl[5]+=strl[2].UrlEncode("EUC-JP"); set: strl[5]+="&Format=html"; // //write open: dir=Dir.Desktop file="YahooSendmailPostdata.txt"; //write: w=strl[5]; //write close: // set: str[2]=str[1]; gosub: str[1]=sub.getComposeUrl2; put: value=str[1]; Ex:Http-Post: url=str[1] base=str[2] post=strl[5] postEncode="EUC-JP" O:text=str[100] O:lastUrl=str[101]; if (str[100].IndexOf{"メールは送信されました"} < 0) { write open: dir=Dir.Desktop file="YahooSendmailPostError.txt"; write: w=str[100]; write close: end: } gosub: renameToBack(strl[intl[2]]); break; } culc: intl[1]--; if (intl[1] > 0) { set: str[2]=str[1]; gosub: str[1]=sub.nextMailCreate; jump: GetWritePage; } Ex:SaveCookie: dir=input[3] file="cookie.dat"; end: } :renameToBack { // // strl[0] : param, filename // set: strl[1]=strl[0]; set: strl[1]+=".bak"; file rename: src=strl[0] to=strl[1]; return: } :sub.getLoginPostdata { // // .tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=jp&.bypass=&.partner=&.u=c4e8m4d33alpf&.v=0&.challenge=MQvdxDl.eGakL_ZVez3JaaiohYrA&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.co.jp&.pd=&.protoctl=&login=LOGINNAME&passwd=LOGINPASSWORD // set: strl[1]=".tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=jp&.bypass=&.partner=&.u="; // set: str[5]=".u"; gosub: strl[2]=getLoginPostdata.get_formValue; // set: strl[1]+=strl[2]; set: strl[1]+="&.v=0&.challenge="; // set: str[5]=".challenge"; gosub: strl[2]=getLoginPostdata.get_formValue; // set: strl[1]+=strl[2]; set: strl[1]+="&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.co.jp&.pd=&.protoctl=&login="; set: strl[1]+=input[1]; set: strl[1]+="&passwd="; set: strl[1]+=input[2]; return: strl[1]; } :getLoginPostdata.get_formValue { // // str[100] : in, WebPage // str[5] : key // int[0] : work // set: strl[5]="name=\""; set: strl[5]+=str[5]; set: strl[5]+="\""; set: int[0]=str[100].IndexOf("action=\"https://login.yahoo.co.jp/config/login"); if (int[0] < 0) { put: value="Loginpage error"; end: } set: intl[1]=str[100].IndexOfUsing0(strl[5]); if (intl[1] < 0) { put: value="Loginpage error. value NotFound"; put: value=strl[5]; end: } culc: intl[1]+=strl[5].Length; // set: int[0]=intl[1]; set: intl[1]=str[100].IndexOfUsing0("value="); culc: intl[1]+="value=".Length; set: int[0]=intl[1]; set: intl[1]=str[100].IndexOutofAnyUsing0("=\" "); set: int[0]=intl[1]; set: strl[1]=str[100].SubstringUntilUsing0("\" >"); return: strl[1]; } :sub.getHttpEquivRefresh { // // str[100] : in, WebPage // int[0] : work // set: int[0]=0; set: intl[1]=str[100].IndexOfUsing0_igC("http-equiv=\"Refresh\""); if (intl[1] < 0) { put: value="[sub.getHttpEquivRefresh] ? http-equiv="; return: ""; } culc: intl[1]+="http-equiv=\"Refresh\"".Length; set: int[0]=intl[1]; set: intl[1]=str[100].IndexOfUsing0_igC("url="); if (intl[1] < 0) { put: value="[sub.getHttpEquivRefresh] ? url="; return: ""; } culc: intl[1]+="url=".Length; set: int[0]=intl[1]; set: intl[1]=str[100].IndexOutofAnyUsing0("=\" "); set: int[0]=intl[1]; set: strl[1]=str[100].SubstringUntilUsing0("\" >"); //set: strl[0]="[sub.getHttpEquivRefresh] Got url="; //set: strl[0]+=strl[1]; //put: value=strl[0]; return: strl[1]; } :sub.getComposeUrl { // // str[100] : in, WebPage // // set: strl[1]="onclick=\"window.location='/ym/Compose?"; set: intl[1]=str[100].IndexOf(strl[1]); culc: intl[1]+=strl[1].Length; if (str[100][intl[1]] == "?") { culc: intl[1]++; } culc: intl[1]-="/ym/Compose?".Length; // set: int[0]=intl[1]; set: strl[2]=str[100].SubstringUntilUsing0("';\" "); return: strl[2]; } :sub.get_hostParts { // // str[2] : in, URL (http://jp.f30.mail.yahoo.co.jp/ym/login?.rand=90ltpaokqn1gr) // set: int[0]="http://".Length; set: strl[1]=str[2].SubstringUntilUsing0("/"); set: strl[2]="http://"; set: strl[2]+=strl[1]; return: strl[2]; } :sub.getFromAddress { // // str[100] : in, WebPage // set: int[0]=str[100].IndexOf("fqemail :"); if (int[0] < 0) { put: value="Compose page error, \"fqemail\" NotFound"; write open: dir=Dir.Desktop file="YahooSendmail_fqemailNotFoundError.txt"; write: w=str[100]; write close: end: } culc: int[0]+="fqemail :".Length; set: intl[1]=str[100].IndexOutofAnyUsing0(" : \""); set: int[0]=intl[1]; set: strl[1]=str[100].SubstringUntilUsing0("\" ,"); return: strl[1]; } :sub.get_crumb { // // str[100] : in, WebPage // set: int[0]=str[100].IndexOf("name=\".crumb\""); if (int[0] < 0) { put: value="[sub.get_crumb] Compose page error, name=\".crumb\" NotFound"; write open: dir=Dir.Desktop file="YahooSendmail_crumbNotFound.txt"; write: w=str[100]; write close: end: } culc: int[0]+="name=\".crumb\"".Length; set: int[0]=str[100].IndexOfUsing0("value="); culc: int[0]+="value=".Length; set: int[0]=str[100].IndexOutofAnyUsing0("=\""); set: strl[1]=str[100].SubstringUntilUsing0("\" >"); return: strl[1]; } :sub.getComposeUrl2 { // // str[100] : in, WebPage // //
  • メールの作成 // Ctrl+shift+P
  • set: intl[1]=str[100].IndexOf(".mail.yahoo.co.jp/ym/Compose?YY="); if (intl[1] < 0) { put: value="[sub.getComposeUrl2] URL \"/ym/Compose?YY=\" NotFound"; end: } set: intl[2]=intl[1]; culc: intl[2]+=".mail.yahoo.co.jp/ym/Compose?YY=".Length; if (str[100][intl[2]] == "=") { culc: intl[2]++; } set: int[0]=intl[2]; set: strl[2]=str[100].SubstringUntilUsing0("&?>\" "); // set: int[0]=intl[1]; set: int[0]=str[100].LastIndexOfUsing0("http://"); if (int[0] < 0) { put: value="[sub.getComposeUrl2] ? URL"; end: } set: strl[3]=str[100].SubstringUntilUsing0("?"); // set: strl[3]+="?YY="; set: strl[3]+=strl[2]; return: strl[3]; } :sub.nextMailCreate { // // str[100] : in, WebPage // str[2] : base URL // // set: int[0]=str[100].IndexOf(".location='/ym/Compose?YY="); if (int[0] < 0) { put: value="[sub.nextMailCreate] ? /ym/Compose?YY= NotFound"; end: } culc: int[0]+=".location='".Length; set: strl[10]=str[100].SubstringUntilUsing0("& ';>"); gosub: strl[9]=sub.get_hostParts; set: strl[9]+=strl[10]; return: strl[9]; }