on 01-28-2020 7:35 PM
Hi guys,
i have problem when tried save file (.xlsx) attachment in folder path.
I saw the documentation before, this : https://contextor.eu/dokuwiki2/doku.php?id=lib:office:outlook#attachmentsave_oindex_path_object
that is my code,
any help?
Regards,
Hello everyone,
I have a problem on save mail attachment part. I checked your solutions above. But I couldn't solve my problem.
- Filenames.push? I don't know this functionality, is it mandatory to use in this code scope?
- Can' I use attachmentSave function like
ctx.outlook.mail.attachmentSave(i,"C:\\Users\\---\\Desktop\\FromEmail\\Attachmentname.xlsx",1);
- Is there a correct example?
Thank you all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bengu, you should use object parameter after path,
Here my example;
var res = ctx.outlook.mail.getFilteredTable();
ctx.log("Mail length: " + res.length,e.logIconType.Info);
for(var i = 0 ;i < res.length;i++){
ctx.outlook.mail.retrieveMail({EntryID : res[i]['EntryID'], StoreID : res[i]['StoreID']});
}
ctx.log("Mail getCollectionLength: " + ctx.outlook.mail.getCollectionLength(),e.logIconType.Info);
for (var i = 0;i< ctx.outlook.mail.getCollectionLength();i++){
ctx.log("Mail i:" + i,e.logIconType.Info);
ctx.log("Mail from :" + ctx.outlook.mail.getSenderAddress(i));
ctx.log("Mail Subject :" + ctx.outlook.mail.getSubject((i)));
ctx.log("Mail Body :" + ctx.outlook.mail.getBody((i)));
ctx.log("Mail Attachments :" + ctx.outlook.mail.getAttachmentsCount((i)));
for (var j=0;j<ctx.outlook.mail.getAttachmentsCount((i));j++){
ctx.outlook.mail.attachmentSave(i,
"C:\\Users\\...\\RPA\\" + ctx.outlook.mail.getAttachmentsName(i)[j],
{Index : ++j} );
}
}
Hi Bengu,
Here is what I used to recursively save attachments from certain emails. I saved my attachments in the log file of the project. I hope it helps
for(i=0; i<mails.length; i++) {
ctx.outlook.mail.retrieveMail({EntryID : mails[i]['EntryID'], StoreID : mails[i]['StoreID']});
}
//Display some info about each email.
ctx.log("---------------------------------------------------------");
for(i=0; i<ctx.outlook.mail.getCollectionLength(); i++) {
ctx.log("Mail no: " + i);
ctx.log("From: " + mails[i]['Sender']);
ctx.log("Subject: " + ctx.outlook.mail.getSubject(i));
ctx.log("---------------------------------------------------------");
//Here we start the procedure of downloading the attachments in the email (if they exist).
//Get the number of attachments for each email.
noAttachments = ctx.outlook.mail.getAttachmentsCount(i);
//Get the name of the attachments.
attachments = ctx.outlook.mail.getAttachmentsName(i);
//Download the attachments if they exist.
if (noAttachments > 0) {
//Save each attachment separately.
for(j=0; j<noAttachments; j++){
filename = attachments[j];
path = ctx.options.path.log + "\\" + filename;
ctx.outlook.mail.attachmentSave( i, path, { AttachmentName: filename } );
ctx.log('File downloaded: '+filename);
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Edgar,
what I see in the error message is "AttachmentName". Please check your code if you use "AttachmentName". If yes insert an 's' after Attachment.
Here an example:
fileNames.push(filePath+"\\"+ctx.outlook.mail.getAttachmentsName(i)[0]);
ctx.outlook.mail.attachmentSave(i, filePath+"\\"+ctx.outlook.mail.getAttachmentsName(i)[0] ,object);
ctx.outlook.mail.setUnRead(i);
Br,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, another mail server
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thanks Peter!
I saw my error , other question!
I can modified other mail server for the automatization?
thanks
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
Yes, i has check out library of Outlook
any help ?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Edgar,
did you activate the outlook library in your project?
Br,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.