1

I'm working in an app that provides you a file with different events (icalendar file) and when I want to send to my Gmail account, adding METHOD='REQUEST'only I can add automatically the first event in my gmail account. Maybe the problem is with Gmail, but I think that's improbably that you only can create a file with one event and send it, because create a file with five or six events it's not so hard to see. I attach here the code of the .py program that send the email:

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase
from email import encoders
import os 

fromaddr = "adress@gmail.com"
toaddr = mail.strip()
msg = MIMEMultipart('alternative')
msg['From'] = "fromaddr"
msg['To'] = 'receiver adress'
msg['Subject'] = "Calendar" 
body = """The hole body"""
msg.attach(MIMEText(body, "html"))
filename = "file.ics"
part = MIMEBase('text', 'calendar',method='REQUEST',name=filename) #method ='REQUEST' only provide me the possibility of adding 1 event, not 5
part.set_payload(cal.to_ical()) #cal is created in a previous step, multiple events
encoders.encode_base64(part)
part.add_header('Content-Disposition', "attachment; filename= %s" % filename) 
msg.attach(part)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "password")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
Hitesh Kalwani
  • 573
  • 5
  • 9
A.Piquer
  • 414
  • 9
  • 23
  • Have you check this related [SO question](http://stackoverflow.com/questions/8856117/how-to-send-email-to-multiple-recipients-using-python-smtplib)? – abielita May 28 '16 at 10:20
  • The fact is that I want to send multiple events to the same email, no to different emails. – A.Piquer May 28 '16 at 13:18
  • I've tried the same thing recently, but I've given up since having multiple invites in a single email doesn't seem to be supported very well. None of the services or clients I've tried was able to handle this. You really should send multiple emails instead. – Marten Jun 06 '16 at 22:15
  • The problem is that I would have to send 15 emails and is very awful. A few days ago Gmail allowed me to add 7 events at the same time and I don't know why It could be done in the same way with all the events that I sent. I have sent an email to GMAIL to know why this is happening but I don't thinkt that the'll ask my question. @Marten – A.Piquer Jun 08 '16 at 09:11

0 Answers0