# Error sending email , expected MIME Type, got Null?

**URL:** <https://forum.inductiveautomation.com/t/error-sending-email-expected-mime-type-got-null/77710>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [August 10, 2023, 5:40pm UTC](https://forum.inductiveautomation.com/t/error-sending-email-expected-mime-type-got-null/77710 "2023-08-10T17:40:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 10, 2023, 5:40pm UTC](https://forum.inductiveautomation.com/t/error-sending-email-expected-mime-type-got-null/77710/1 "2023-08-10T17:40:07Z")

</div>

Using 7.9.23. Trying to send a report with the following script -

```auto
def sendReport(endDateDT=None):
    """
    How will we determine what counts as marked? should marked really be a datetime? Perhaps. Or based on when the entry was entered?
    An old entry from months ago that gets marked this week - should that be sent for instance.
    """
    LOGGER.info("Trying to send report")
    if endDateDT is None:
        endDateDT = system.date.now()
    LOGGER.info("Using date %s"%(str(endDateDT)))
    reportName = 'DPD Weeklies Projects Updates'
    action = 'email'
    reportParameters = {'endDate':endDateDT}
    endDate = system.date.format(endDateDT, 'yyyy-MM-dd')
    project = 'DPDWeeklies'
    body = "Cooleagues,\n\nBelow are the project updates for the week.\n\nPlease feel free to reach out if you have any questions regarding the updates.\n\nThanks"
    actionSettings = {'to':['keyur.parikh@bms.com'], 'smtpServerName':'Weekly Hot Topics Mailer', 'from':'DPDWeeklies@bms.com', 'subject':'DPD Weeklies w/e %s'%(endDate),"body":body}
    reportData = system.report.executeReport(path=reportName, project=project, parameters=reportParameters, fileType='pdf')
    fileName = 'DPD Weeklies Updates %s'%(str(endDate))
    print fileName
    print type(reportData)
    system.net.sendEmail(smtpProfile='Weekly Hot Topics Mailer', fromAddr='testEmail@test.com', subject='DPD Weeklies w/e %s'%(endDate), body=body, to=['testEmail@test.com'], attachmentNames=[fileName], attachmentData=[reportData])
# system.report.executeAndDistribute(path=reportName, project=project, parameters=reportParameters, action=action, actionSettings=actionSettings)
    LOGGER.info("Finished trying to send report")

```

I am getting an error on the system.net.sendEmail part the error and not sure why. Apologies for screen shot, operator is remoted in a few layers deep and cannot copy paste for some reason -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1ededbdf5139b27efe822cd0329817eac3f1a315.jpeg)

My sendEmail line does work if I leave off the attachmentNames and attachmentData kwargs, so I hting that is the issue but I don't know why. My print statements shows the filename to be `DPD Weeklies Updates 2023-08-18` and the type of `reportData` as `<type 'array.array'>`. Any ideas what is going on?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 10, 2023, 6:06pm UTC](https://forum.inductiveautomation.com/t/error-sending-email-expected-mime-type-got-null/77710/2 "2023-08-10T18:06:20Z")

</div>

Good news; we already fixed the underlying limitation here and made it more flexible.  
Bad news: it's fixed in 8.1.22 and up.

See this thread for more context:

> [@Sending email with .ics attachment](https://forum.inductiveautomation.com/t/sending-email-with-ics-attachment/57875):
>
> Hello everybody, I want to send an Email with an attachment with “.ics” extension. However, i have this error message Any solutions ? Thanks in advance

And more details on how it works are in system.net.sendEmail:  
[https://docs.inductiveautomation.com/display/DOC81/system.net.sendEmail](https://docs.inductiveautomation.com/display/DOC81/system.net.sendEmail)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 10, 2023, 6:32pm UTC](https://forum.inductiveautomation.com/t/error-sending-email-expected-mime-type-got-null/77710/3 "2023-08-10T18:32:27Z")

</div>

Ah. Ok. Unfortunately this customer has no impending plans to upgrade to 8.1.xx or pay for the 8 license in the forseeable future but luckily Phil linked [https://javaee.github.io/javamail/docs/api/](https://javaee.github.io/javamail/docs/api/) so I will have to give it the old college try myself.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 15, 2023, 12:38pm UTC](https://forum.inductiveautomation.com/t/error-sending-email-expected-mime-type-got-null/77710/4 "2023-08-15T12:38:50Z")

</div>

I got this working without any using java libraries or upgrading.

Changing this -  
`fileName = 'DPD Weeklies Updates %s'%(str(endDate))`  
to  
` fileName = 'DPD Weeklies Updates %s.pdf'%(str(endDate))`  
made everything work correctly.
