// Filter Email Attachments
ctx.fso.init();
ctx.outlook.init();
var emails =[]
var i, j, path, filename, attachments, noAttachments, extract, spreadsheet;
// Resets the working email list.
ctx.outlook.mail.resetMailCollection();
// Search email with subject name
ctx.outlook.mail.searchByCriteria({
subject: "Attachment",
hasAttachment: true,
dontThrowExceptionIfNoMailFound: true
});
// Get the list of email information for the emails that fit the criteria.
emails = ctx.outlook.mail.getFilteredTable();
if(emails.length){
for (i = 0; i < emails.length; i++){
ctx.outlook.mail.retrieveMail({
EntryID: emails[i]['EntryID'],
StoreID: emails[i]['StoreID']
});
}
// Display some information about each email
for(i = 0; i < ctx.outlook.mail.getCollectionLength(); i++){
ctx.log("Email No:" + i);
ctx.log("From:" + emails[i]['Sender']);
ctx.log("Subject:" + ctx.outlook.mail.getSubject(i));
// Get the number of attachments of each email.
noAttachments = ctx.outlook.mail.getAttachmentsCount(i);
// Get the name of attachments
attachments = ctx.outlook.mail.getAttachmentsName(i);
spreadsheet = ctx.fso.file.getExtensionName(filename);
// 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("FileName:" + filename);
var ExtensionName = ctx.fso.file.getExtensionName(ctx.options.path.log + "\\" + filename, true);
var File = ctx.options.path.log + "\\" +filename;
var FileName = ctx.fso.file.getFileName(File);
if(ctx.options.path.log + "\\" + filename && "xlsx" === ExtensionName){
ctx.excel.file.open(File);
ctx.excel.file.saveAsPDF(0, ctx.options.path.log + "\\filename.pdf");
}
ctx.log("File Extension is:" + ExtensionName);
}
}
}
}
// Ends Microsoft Outlook application.
ctx.outlook.end();
ctx.fso.end();
sc.endStep(); // end Scenario
return;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |