I have designed a workflow for extracting email data in which user will give the number of emails he want to read, then user will select an option, based on which option he wants to extract the data( Email ID of the Sender, Sender Name, Email Subject), then BOT will filter the data based on that option and then write the filtered data into excel.
Now, in this workflow, I want to add that based on the input, BOT should check that email has attachment or not, if an email has attachment, then BOT should save the attachment and write the details into excel.
My BOT is working in that way that from the number of mails, it is checking that if email has attachment then it is saving the attachment. But it should first filter based on the user input. I don’t know, where I am wrong.
Thanks for your response. I am using Gmail account and I have read the inbox by asking the user about the number of emails. Then by using for each, I have looped each email and used the if condition like if(mail.Attachments.Any) , this will collect all the emails which have attachment in a variable.
Then user will select, based on what he wants to download the attachment, then I am inputting the value and the details are also saved in excel along with Attachment Name.
I am not getting, where to use the “save attachment”, because if I use save attachment in the for loop above, then it will save all the attachments. And outside that for loop, how can I save the attachment, because I would need to use “mail” or “item” that could be of type “system.net.mail.mailmessage”. I hope, I have elaborate it right.
I was using DT because as it iterate through each mail, it will save Sender Name, email id, email body to a variable DT, where I used Add Data Row. So that it could help in filteration part. Because in the end, I need all the seperate value to write into excel. Is there any way to achieve the results with this logic.?? Because if we don’t change into DT, after filteration, the result will come in DT. And for filteration, I need 2 DT, one for input and one for output.
Yes, I can access these values. But my point, Suppose all the emails are in list, then for filtering, I would need the values, where I could set the condition. And If after filtering, I used for each to loop through each email, then it will loop through each email and not through the filtered one. I don’t know, May be I am not elaborating right.
I would need to use different for each for different user input, i.e. one for email id of sender, one for sender name and one for email subject… Like this you are saying…??
Sorry to bother you again. But I tried the way you told yesterday. The statement “mailList.Where(function(mail) mail.Subject.Equals(”“)).ToList” is not filtering any mail. After inputting the text, the variable does not have any mail that is filtered, the email is present in the emaillist.
Can you please help with this. Thanks