Question: I have python code that looks like below. It works fine when executed manually. But when executed via a cronjob, the email is not being sent. Here is the code:

```
msg = MIMEMultipart()

msg['From'] = sender
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(message))

mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(login, password)
print mailServer.sendmail(login, to, msg.as_string())

```

Answer: 
It appears your error is occurring on the first ADDFILE call.

Try making your directory references upper case: directory => 'DPUMP\_DIR'
Try this:

```
dbms_datapump.metadata_filter(      
      handle => dp_handle,
      name   => 'TABLESPACE_EXPR',
      value  => '=''COURSE''');

```

---

> 
> "I still get the same error messages
>  though"
> 
> 
> 

Hmmm.... Remote debugging of other people's code is one of the least fun aspects of SO. Anyway, let's give it another guess. 

Do you have an OS directory called `/mydata/data` which Oracle has read and write privileges on? The CREATE DIRECTORY statement only creates a pointer, it doesn't create the underlying OS directory.