I would like to extract the following OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
Products:
------------------------------------------------------------------
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
In the e-mail, you will receive the name of the item with the dotted line after the item:I can extract other parts using the match method, but I don't know how to extract them because the product name doesn't come after the product.There are many more types of products, and even if you use the match method, the spreadsheet will only spread sideways.So I would like to know how to extract only certain lines of OOOOOOOO.
I would like to specify the line (actual product name) that comes after the dotted line and have it written on the extraction spreadsheet.
The scripts I use are as follows:
function fetchContactMail(){
var strTerms='(is:unread "OOOOOOOOOOOOOOOOOOO);
varmyThreads=GmailApp.search(strTerms,0,10);
var myMsgs=GmailApp.getMessagesForThreads(myThreads);
varvalMsgs=[];
for (vari=0;i<myMsgs.length;i++){
valMsgs[i]=[];
valMsgs[i][0] = myMsgs[i][0].getDate();
valMsgs[i][1] = myMsgs[i][0].getFrom();
valMsgs[i][2] = myMsgs[i][0].getSubject();
valMsgs[i][3] = myMsgs[i][0].getPlainBody().match(/OOOOO(.+)/);
valMsgs[i][4] = myMsgs[i][0].getPlainBody().match(/OOOOOOO(.+)/);
valMsgs[i][5] = myMsgs[i][0].getPlainBody().match(/OOO(.+)/);
valMsgs[i][6] = myMsgs[i][0].getPlainBody().match(/OOO(.+)/);
valMsgs[i][7] = myThreads[i].getPermalink();
myMsgs[i][0].markRead();
}
if(myMsgs.length>0){
varmySheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName('OOO');
varmaxRow=mySheet.getDataRange().getLastRow();
mySheet.getRange(maxRow+1,1,i,9).setValues(valMsgs);
}
}
The 0000...
portion of the above format can be retrieved using the following regular expressions:
/Product:\n-+\n(.*)/
This takes advantage of the fact that \n
means a new line.
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.