# email connector  attachment error

**URL:** <https://community.ofelia.com/t/email-connector-attachment-error/9502>\
**Category:** Q&A\
**Created:** [6 March 2019 19:55 UTC](https://community.ofelia.com/t/email-connector-attachment-error/9502 "2019-03-06T19:55:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![donghee.baik](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@donghee.baik](https://community.ofelia.com/u/donghee.baik)\
**Post date:** [6 March 2019 19:55 UTC](https://community.ofelia.com/t/email-connector-attachment-error/9502/1 "2019-03-06T19:55:01Z")

</div>

Hello,

I created an email connector with attach files&nbsp;and it works well.

When I attach the file, it works well. However, once I didn't&nbsp;attach the file, it has an error.

I validate formOutput like :&nbsp;

if($data.formInput.authdocumentDocumentInput){  
&nbsp; &nbsp; return {  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;'authdocumentDocumentInput': $data.formInput.authdocumentDocumentInput&nbsp;  
&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;};&nbsp;  
&nbsp; &nbsp;&nbsp;  
}else{  
&nbsp; &nbsp; return {  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;'authdocumentDocumentInput': null&nbsp;  
&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;};  
}

But, the error occurred when I didn't&nbsp;attach the file.

Caused by: org.bonitasoft.engine.connector.ConnectorException: org.bonitasoft.engine.connector.ConnectorException: unable to retrieve attachments for the email.

Caused by: org.bonitasoft.engine.connector.ConnectorException: unable to retrieve attachments for the email

Caused by: org.bonitasoft.engine.bpm.document.DocumentNotFoundException: USERNAME=ConnectorAPIAccessorImpl | org.bonitasoft.engine.commons.exceptions.SObjectNotFoundException: Document not found: authdocument for process instance: 60037

Did i something miss or do I need to add groovy script in the connector instead of variable?

Any help would be appreciated.

Thanks in advanced.&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [3 April 2019 10:08 UTC](https://community.ofelia.com/t/email-connector-attachment-error/9502/2 "2019-04-03T10:08:07Z")

</div>

I did some test and managed to reproduce your issue.

By looking at [email connector source code](https://github.com/bonitasoft/bonita-connector-email/blob/bonita-connector-email-impl-1.0.15/bonita-connector-email-impl/src/main/java/org/bonitasoft/connectors/email/EmailConnector.java#L454) I think that if email connector is configure to have attachment, the document(s) used as attachment must be initialized.

One workaround I found is to add some logic in the process to initialize the document with an empty value if no file was uploaded. I create an [example](https://www.dropbox.com/s/2r84hfoyhazq8eg/EmailConnectorOptionnalAttachmentDiagram-1.0.bos?dl=0) that demonstrate that.

Another workaround would be to create your own custom email connector.

---

<div class="post-metadata">

**Author:** ![donghee.baik](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@donghee.baik](https://community.ofelia.com/u/donghee.baik)\
**Post date:** [8 April 2019 13:13 UTC](https://community.ofelia.com/t/email-connector-attachment-error/9502/3 "2019-04-08T13:13:44Z")

</div>

Thanks for the answer. However, I could not import the BOS file.  
Would you let me know what is the version of the file?

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [8 April 2019 13:31 UTC](https://community.ofelia.com/t/email-connector-attachment-error/9502/4 "2019-04-08T13:31:04Z")

</div>

I used Bonita Community Edition 7.8.3 to create this example.

---

<div class="post-metadata">

**Author:** ![donghee.baik](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@donghee.baik](https://community.ofelia.com/u/donghee.baik)\
**Post date:** [8 April 2019 13:45 UTC](https://community.ofelia.com/t/email-connector-attachment-error/9502/5 "2019-04-08T13:45:01Z")

</div>

Thanks for the reply. I am using Bonita studio 7.6.3. I will update the studio and will work it again.  
Thanks a lot
