0

I'm facing an issue to send a full network path of Windows as a hyperlink in email using Python, when I send it, users receive a broken link at the first white space in the path :

toaddr = ['mail1@exemple.com']
to_cc = ['mail2@exemple.com', 'mail3@exemple.com']
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = ','.join(toaddr)
msg['CC'] = ','.join(to_cc)
msg['Subject'] = "The report"
path = "\\\\windows_Server\\golobal_directory\\the folder\\file yyymm.xlsx"
body = 'this the body text of the mail'+ path
msg.attach(MIMEText(body, 'plain'))
...

after sending my email, the users receive something like this :

\\windows_Server\golobal_directory\the folder\file yyymm.xlsx

have you any ideas how can fix this ?

thanks !

Merouane Benthameur
  • 1,765
  • 2
  • 13
  • 21
  • 1
    I would recommend to send HTML-Body in your mail, then you can format the link anway you like – Najzero Jun 17 '16 at 06:14

2 Answers2

1

I have a strong feeling that you might have to enclose the entire path in double quotes.

path = "\"\\\\windows_Server\\golobal_directory\\the folder\\file yyymm.xlsx\""
Sudhir K
  • 23
  • 4
0

This solution of enclosing the entire path worked for me. I was running into similar issue sending as a hyperlink in the email.

In addition to adding double quotes around shared drive path:

email_body ='Report! Weve successfully created a report!!  Go to the link : <a href='+str(shared_drive_path)+' >click here</a>'

msg = MIMEText(email_body,'html') 
Dennis Vash
  • 50,196
  • 9
  • 100
  • 118