Question: I would imagine that this has been answered before, but I could not find a thread for that describes the search process exactly. Apologies if I am wrong. I 

What is **exactly** the search process Python follows for finding a module? What **paths** are considered in what order? (e.g. `sys.path` vs `PYTHONPATH` definitions, `site-packages` etc.)

I copied below the information from [the link](https://docs.python.org/2/tutorial/modules.html#the-module-search-path) provided in the comments, the following, but I have the following questions:

* What is the `installation-dependent` default exactly?
* What happens if you have a virtual environment from `virtualenv` or from `conda` activated?

> 
> When a module named spam is imported, the interpreter first searches
>  for a built-in module with that name. If not found, it then searches
>  for a file named spam.py in a list of directories given by the
>  variable sys.path. sys.path is initialized from these locations:
> 
> 
> * The directory containing the input script (or the current directory).
> * `PYTHONPATH` (a list of directory names, with the same syntax as the shell variable `PATH`).
> * The installation-dependent default.
> 
> 
> After initialization, Python programs can modify `sys.path`. The
>  directory containing the script being run is placed at the beginning
>  of the search path, ahead of the standard library path. This means
>  that scripts in that directory will be loaded instead of modules of
>  the same name in the library directory. This is an error unless the
>  replacement is intended. See section Standard Modules for more
>  information.
> 
> 
>

Answer: 
In order to use *gmail* you need SSL, I'am not sure you can use `Send-MailMessage` try this :

```
$emailSmtpServer = "smtp.gmail.com"
$emailSmtpServerPort = "587"
$emailSmtpUser = "yourlogin@gmail.com"
$emailSmtpPass = "yourPassword"

$emailMessage = New-Object System.Net.Mail.MailMessage
$emailMessage.From = "yourlogin@gmail.com"
$emailMessage.To.Add("YourSendTo@mail.com")
$emailMessage.Subject = "Small mail for a friend"
$emailMessage.IsBodyHtml = $true
$emailMessage.Body = @"
<p><strong>Hello me</strong>.</p>
<p>It seems to work</p>
<p>JP</p>
"@

$SMTPClient = New-Object System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort )
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );

$SMTPClient.Send( $emailMessage )

```

---

Edited :

To use mail attachment please have a look [Sytem.Net.Mail.MailMessage](http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage(v=vs.110).aspx) documentation. You need first to create an [Attachment](http://System.Net.Mail.Attachment) and then to add it to the MailMessage `Attacments` collection.
For those that come later, here is my two liner example, for the account "gmail-user@gmail.com". This can be scheduled.

```
$credentials = new-object Management.Automation.PSCredential “gmail-user@gmail.com”, (“gmail-user's password” | ConvertTo-SecureString -AsPlainText -Force)

Send-MailMessage -From "gmail-user@gmail.com" -to "someone-else@gmail.com" -Subject "Some subject"
-Body "Some body" -SmtpServer "smtp.gmail.com" -port 587 -UseSsl
-Credential $credentials -Attachments "C:\an-attachment.txt"

```