How to get outlook email subject into string variable


#1

Hi
I have been trying to assign an email subject to a string variable

I am using the assign function to say

mail.subject is assigned to variable1

however it doesnot seem to be able to capture this…

help?


#2

It should work for string assignment.Are you getting any error? Can you paste screenshot of your code?


#3

hi
this is the code
thanks for your help.
when I print it in msgbox to see …it is not showing anything…
I also wanted to do some string oeprations such as substring to it but doesn’t seem to work…
interestingly… mail.subject.contains() works for me though…


How to read outlook mail subject and save in excel
#4

Hi,

you have it reversed, ‘mail.subject is assigned to variable1’. In your example you are assigning variable(userwithresponse) to mail.subject.

-Topi


How to read outlook mail subject and save in excel
#5

How to save( All Mail subject) in excel ?


#6

Do a foreach loop for all the mails. For each mail add a mail.Subject to a Datatable as a new row, append Datatable to an excel.

br,
Topi


How to read outlook mail subject and save in excel
#7

Hi @neerajmca5,

Refer this Post,

Please try to avoid creating duplicate post.

Regards,
Arivu


#8

can you share xml
Am getting error


#9

Hello everyone, I am trying to get subject of mails iteratively in for each loop
I tried for outlook and IMAP both but not succeeded in both cases

mailActivity.xaml (8.7 KB)
mail_reply.xaml (8.6 KB)

in case of Get Outlook mail message the exception is coming “The specified folder does not exist” I have specified “Inbox” under input MailFolder field, and tried allomost all other solutions given on net like remove emailId from account field and by removing “Inbox” from MailFolder, by running outlook as administrator etc but not succeeded.

In case of IMAP the mail.Subject/mail.subject is throwing compiletime because subject is not applicable/accessible on mail variable which is in forch each loop like (ForEach mail in mailsList)

I checked the type of mail which is System.Net.Mail.MailMessage
what i’m doing wrong? what is the solution of this problem, help is highly appreciable.
i’m sending my XAML file for better understandin


#10

I solved it by specifying for Each activity Misc Type Argument as System.Net.Mail.MailMessage. :slight_smile:


#12

Hi Edgars,
I have attached XAML for the same, only change is i’m using IMAP instead of outlook, but not an issue you can just replace the IMAP with outlook.
Note: you have to assign MailsList as a System.Collections.Genric<System.Male.MaleMessage> variable type
and for loop Type Argument as System.Male.MaleMessage
ask me if you are facing any issue further
ReadMail.xaml (6.2 KB)


#13

I have specified Inbox is my folder but it shows the below exception,

Source: Get outlook mail messages
Message: The specified folder does not exist
Exception Type: ArgumentException
System.ArgumentException: The specified folder does not exist
   at UiPath.Mail.Activities.GetMailActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
   at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)