Hey,
I am trying to send a vcard as an attachment.
I can generate a basic vcard without problem from contact details. I am then generating a binary file with proper mime type.
However, when I try to send the email, I get the following error message:
Has anyone done something similar? Am I going about it the right way?
Thanks in advance,
This is the workflow:
{
"nodes": [
{
"parameters": {
"functionCode": "// create vCard\n\nvar contact = items[0].json.contact;\n\n\nvCard = 'BEGIN:VCARD\\nVERSION:4.0\\n';\nvCard += 'FN:'+ contact.first_name + ' ' + contact.last_name + '\\n';\nvCard += 'N:'+ contact.last_name + ';' + contact.first_name + ';;\\n';\nvCard += 'EMAIL:'+ contact.email + '\\n';\nvCard += 'TEL;TYPE=work,voice;VALUE=uri:tel:'+ contact.phone + '\\n';\nvCard += 'NOTE:Contact créé par n8n\\n';\nvCard += 'END:VCARD';\n\nitems = [ { 'json' : { 'data' : vCard } }];\n\nreturn items;"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
700,
300
]
},
{
"parameters": {
"mode": "jsonToBinary",
"convertAllData": false,
"options": {
"fileName": "contact.vcf",
"mimeType": "text/vcard",
"useRawData": true
}
},
"name": "Move Binary Data",
"type": "n8n-nodes-base.moveBinaryData",
"typeVersion": 1,
"position": [
980,
300
],
"alwaysOutputData": false
},
{
"parameters": {
"functionCode": "// initiate contact details\n\nvar contact = {\n 'first_name' : 'My',\n 'last_name' : 'Contact',\n 'phone' : '+123456789',\n 'email' : '[email protected]'\n}\n\n\nitems = [ { 'json' : { 'contact' : contact } }];\n\n\nreturn items;"
},
"name": "Function1",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
460,
300
]
},
{
"parameters": {
"fromEmail": "[email protected]",
"toEmail": "[email protected]",
"text": "this is your new contact",
"attachments": "={{$binary}}",
"options": {}
},
"name": "Send Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 1,
"position": [
1200,
300
],
"credentials": {
}
}
}
],
"connections": {
"Function": {
"main": [
[
{
"node": "Move Binary Data",
"type": "main",
"index": 0
}
]
]
},
"Move Binary Data": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
},
"Function1": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
}
}
}