i have few fields in excel whose data i need to search in office 365
for example if cell A2 contains company name , i need to search company name in office 365 . the data can either be in mail attachment or in the body of the mail and need to download it .
Use ‘Excel Application Scope’ to read the company names from Excel into a DataTable.
Get Outlook Mail Messages:
Use ‘Get Outlook Mail Messages’ to retrieve emails from your Office 365 mailbox.
Iterate Through Emails:
Use ‘For Each’ to loop through each email obtained in the previous step.
Search for Company Name:
Inside the loop, check if the company name from Excel is present in the email’s subject, body, or attachments.
Download Attachments:
If the company name is found, use ‘Save Attachments’ to download them to a specified folder.
Logging and Reporting:
Log relevant information using ‘Log Message’ and consider reporting the downloaded files for record-keeping.
Here’s a simplified pseudocode:
plaintextCopy code
Excel Application Scope
Read Range (A2 company names into DataTable)
Get Outlook Mail Messages
For Each mail in mailMessages
If mail.Subject.Contains(companyName) Or mail.Body.Contains(companyName) Or AttachmentContainsCompanyName(mail.Attachments)
Save Attachments
Log Message ("Downloaded attachment from email: " + mail.Subject)
End If
End For Each
Replace companyName with the actual company name, and create a custom function (AttachmentContainsCompanyName) to check if any attachment contains the company name.
Ensure you handle authentication and security considerations appropriately.
i have given get outlook mail message an output variable and then for other activity
for each Currentitem i have given in option as variable of get outlook mail message
in body i need to give if activity right ? and the condition i m not getting there
Read Range
For Each row in dtCompanies
Get Outlook Mail Messages (Filter: "Subject = '" + row("CompanyName").ToString + "'")
For Each Currentitem in retrievedEmails
If Currentitem.Subject.Contains(row("CompanyName").ToString) Or Currentitem.Body.Contains(row("CompanyName").ToString) Then
Save Attachments
End If
Next
Next
can we connect over call for this issue ? this is very critical and i need to finish off within today … if you feel right can you call me on 8248882693
→ I used Get outlook mail message activity to retrieve the mails from the outlook and store in a Variable called Mailmessages it is List<mailmessage> datatype.
→ The output of Get outlook mail message activity give the input to the for each in List of items block.
→ Insert If activity inside the For each then try to give the Condition as below
currentItem.Subject.Equals("ABCD")
Note - When you hit on Ctrl+Space to get the subject, sometimes it will not work in that time just type the condition what you want.
For testing i have given read cell activity and varaible for it .
if i give that variable name instead of company name will that work ?mail.Subject.Contains(companyName) Or mail.Body.Contains(companyName) Or AttachmentContainsCompanyName(mail.Attachments)