# Variable type mismatch

**URL:** <https://forum.uipath.com/t/variable-type-mismatch/6562>\
**Category:** Help\
**Tags:** mail, activities\
**Created:** [June 20, 2017, 11:36am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562 "2017-06-20T11:36:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 20, 2017, 11:36am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/1 "2017-06-20T11:36:55Z")

</div>

To get IMAP mail messages i saved those messages in a variable of type System.Collections,Generic.List(System.Net.Mail.MailMessage)  
But when I’m trying to save the mail message using the same variable then it shows error "value of System.Collections,Generic.List (Of System.Net.Mail.MailMessage) can’t be converted to System.Net.Mail.MailMessage  
(No error is shown in the Get IMAP Mail container but error pops up in the container related to saving mail message)

Please give me some suggestions on how to solve this problem

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 20, 2017, 11:46am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/2 "2017-06-20T11:46:15Z")

</div>

hope your processing via **foreach** loop  
the variabel which store the mail is in list .So while processing through foreach loop it should item by item  
please change the variable type to " **System.Net.Mail.MailMessage"**

 ![](https://global.discourse-cdn.com/uipath/original/2X/6/69a8cea34aa7906d18a3d259913c11528eb9e8f9.png)

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 3:30am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/3 "2017-06-21T03:30:35Z")

</div>

Have a look. I have to complete the body part of foreach.

 ![](https://global.discourse-cdn.com/uipath/original/2X/9/9239657263fc8dc25750e3e515560793925c8c1a.png)

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 4:29am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/4 "2017-06-21T04:29:57Z")

</div>

looks like you got me wrong. 😛  
Keep your "get IMAP message output variable (eg: **mail** ) type as **List of System.Net.Mail.MailMessage**

when you pass the same variable (eg: **mail** ) in foreach just change the TypeArgument as **“System.Net.Mail.MailMessage”** keep default **item** as it is.

please see the screen shot.

 ![](https://global.discourse-cdn.com/uipath/original/2X/1/1eceec90fa467140ff5fc1b54580f6327d0c54c2.png)

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 4:46am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/5 "2017-06-21T04:46:15Z")

</div>

Can you tell me how to save a mail or an attachment? I am facing problems in item.Body.Contains(“”) part. What should I write in the quotes?

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 4:52am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/6 "2017-06-21T04:52:26Z")

</div>

we have **save attachment and Save Mail Message**  **activity**

if you want to save attachment depends on subject or sender name or any condition for eg.

 ![](https://global.discourse-cdn.com/uipath/original/2X/b/b3f7f23f19ffb4b68b19ae43a8f1ff2f8380c65f.jpg)

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 4:56am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/7 "2017-06-21T04:56:47Z")

</div>

Why did you take the assignment block?

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 4:57am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/8 "2017-06-21T04:57:52Z")

</div>

that’s for further operation on attachment so i can read the excel files from the file path.  
Anyway that not required in your case .

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 5:07am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/9 "2017-06-21T05:07:00Z")

</div>

It’s not working. The attachment doesn’t get downloaded, nor the further sequence gets executed.

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 5:10am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/10 "2017-06-21T05:10:43Z")

</div>

whats the error? attach workflow.

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 5:15am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/11 "2017-06-21T05:15:49Z")

</div>

There isn’t any sort of error.

 ![](https://global.discourse-cdn.com/uipath/original/2X/6/6ed704d757ba55c8bdcd3b9fc629ec4641aa17a9.png)

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 5:21am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/12 "2017-06-21T05:21:28Z")

</div>

after condition does it entering into “ **then** ” sequence ?  
if not make sure your subject is right. just change subject as “document\_Sana”

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 5:36am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/13 "2017-06-21T05:36:59Z")

</div>

Nothing seems to work I’m afraid. I’m stuck with this.

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 5:39am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/14 "2017-06-21T05:39:43Z")

</div>

🤔 does your Get IMAP Mail Messaging reading the mail?

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 5:42am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/15 "2017-06-21T05:42:18Z")

</div>

It just opens up the [gmail.com](http://gmail.com) page and nothing else

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 5:43am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/16 "2017-06-21T05:43:55Z")

</div>

by default “ **OnlyUnReadMessages** ” checked .  
please keep some unread mail in gmail and try again.

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 6:03am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/17 "2017-06-21T06:03:35Z")

</div>

What should be the variable type of password?

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 6:06am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/18 "2017-06-21T06:06:38Z")

</div>

its just a string

---

<div class="post-metadata">

**Author:** ![sanap](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sanap](https://forum.uipath.com/u/sanap)\
**Post date:** [June 21, 2017, 6:13am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/19 "2017-06-21T06:13:07Z")

</div>

Still not working. Should I leave this and try other samples?

---

<div class="post-metadata">

**Author:** ![ddpadil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ddpadil/32/49955_2.png) [@ddpadil](https://forum.uipath.com/u/ddpadil)\
**Post date:** [June 21, 2017, 6:21am UTC](https://forum.uipath.com/t/variable-type-mismatch/6562/20 "2017-06-21T06:21:21Z")

</div>

sure. I don’t know why you unable to do so.☹  
All the best.

[Next page](https://forum.uipath.com/t/variable-type-mismatch/6562.md?page=2)
