I'm trying to send vCard files (which allow you to save contacts on mobile devices) using Twilio's API and vobject.
Here's my code:
import vobject
import requests
from twilio.rest import Client
account_sid = 'MY_SID_HIDDEN'
auth_token = 'AUTH_TOKEN_HIDDEN'
j = vobject.vCard()
j.add('n')
j.n.value = vobject.vcard.Name(family='Harris', given='Jeffrey')
j.add('fn')
j.fn.value = 'Jeffrey Harris'
j.add('email')
j.email.value = '[email protected]'
j.email.type_param = 'Internet'
client = Client(account_sid, auth_token)
client.api.account.messages.create(
to="NUMBER_HIDDEN",
from_="NUMBER_HIDDEN",
body=j
)
When my device receives the message, it looks like this:
<VCARD| [<EMAIL{'TYPE': ['Internet']}[email protected]>, <FN{}Jeffrey Harris>, <N{} Jeffrey Harris >]>
Why is this happening?
I understand what you want to do, but there are a couple issues.
Note: I'm not sure if the mime-type is required anymore, as they don't use it on this example for a attaching picture (https://www.twilio.com/docs/api/messaging/send-messages#send-a-message-with-an-image-url ; change the language to python).
You would attach the file (vcard) using mediaUrl.
ex//
mediaUrl=https://qrstuff.com/vcard.download/dec91a6d6/yo_yo_ma_vCard.vcf