I am trying to attach a link to my local file while sending an email using python smtplib.
msg.attach(MIMEText(u'<a href="file:///C:\folder\file.txt">Link</a>', 'html'))
But it just comes as plain text in the email.
If I just use the link in a html page the link works.
<html>
<a href="file:///C:\folder\file.txt">Link</a>
</html>
How do I solve this?
Edit:
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
....
....
....
msg = MIMEMultipart()
msg['From'] = self.username
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(text))
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(self.username, self.password)
mailServer.sendmail(self.username, to, msg.as_string())
My code snippet of sending email is very similar to this