2017-11-04 9 views
1

Outlook 및 iOS 메일 앱에서 캘린더 이벤트로 인식하는 캘린더 이벤트를 캘린더 이벤트로 전송하는 데 문제가 있습니다.Mailgun : 캘린더 모임 이벤트/요청 보내기

node.js에서 JavaScript를 사용하고 있습니다. 이메일을 보내려면 mailgun과 js 라이브러리 mailgun-js을 사용하고 있습니다. 나는 ics 파일을 만들고 전자 메일에 첨부하고 있습니다.

const mailgun = require('mailgun-js')({apiKey: mailgunApiKey, domain: mailgunDomain}) 

const candidateEmailBody = { 
    from: `${companyName} <${EMAIL_FROM}>`, 
    to: email, 
    subject: companyName + ' - interview', 
    html: 'Html message', 
    attachment: [invite] 

    } 

    mailgun.messages().send(candidateEmailBody, function (error, body) { 
    if (error) { 
     console.log(error) 
    } 
    }) 

invite 물체가 아래의 기능에 의해 ics lib 디렉토리에 의해 만들어지고 mailgun의 첨부 파일에 싸여 :

const prepareIcsInvite = function (startDate, companyName, firstname, lastname, email, intFirstname, intLastname, intEmail) { 
    const st = new Date(startDate) 
    const meetingEvent = { 
    start: [st.getFullYear(), st.getMonth() + 1, st.getDate(), st.getHours(), st.getMinutes()], 
    end: [st.getFullYear(), st.getMonth() + 1, st.getDate(), st.getHours()+1, st.getMinutes()], 
    title: companyName + ' - Interview', 
    description: 'description', 
    location: 'location', 
    status: 'CONFIRMED', 
    productId: 'myproduct', 
    organizer: {name: 'Admin', email: '[email protected]ample.com'}, 
    attendees: [ 
     {name: firstname + ' ' + lastname, email: email}, 
     {name: intFirstname + ' ' + intLastname, email: intEmail} 
    ] 
    } 

    const icsFile = ics.createEvent(meetingEvent) 
    const fileData = new Buffer(icsFile.value) 

    const invite = new mailgun.Attachment(
    { 
     data: fileData, 
     filename: 'Meeting Invite.ics', 
     contentType: 'text/calendar' 
    }) 
    console.log('ICS meeting invite created') 
    return invite 
} 

이메일 그런 식으로 준비가 mailgun API를 통해 전송되고 Gmail은 올바르게 모임 초대로 인식 : 그러나

enter image description here

, 다른 이메일 클라이언트 (아이폰 OS, 아웃룩) 이것이 캘린더 일정 초대임을 인식하지 못하고 파일 첨부와 함께 일반 이메일로 표시하십시오.

이 메시지를 작성하려면 어떻게해야합니까? Outlook과 iOS는 호환 가능합니까?

답변

1

Outlook (그리고 iOS도 마찬가지입니다.) "초대장"을 사용하여 초대장을 저장합니다.

이 GitHub 문제는 MIME 라이브러리를 사용하여 이벤트 메시지를 작성하는 방법을 설명합니다. https://github.com/bojand/mailgun-js/issues/44. 이 문제에서 설명한 동일한 코드 흐름을 사용하여 메시지를 작성할 수 있어야합니다. 당신은에 대한 ics.createEvent에서 반환 된 문자열 값을 사용해야합니다 'addAlternative "전화.

Mailcomposer가 Mailgun 워드 프로세서 (https://documentation.mailgun.com/en/latest/api-sending.html#examples)에서 참조 MIME 라이브러리입니다.

+0

안녕 조 P. GitHub의 문제를 당신에게' 언급 된 내용은 2014 년 9 월부터이며 더 이상 지원되지 않는 메일 그룹 lib의 이전 버전을 나타냅니다. – Pawel

+0

@Pawel GitHub 문제가 발생 했음에도 불구하고 접근 방식은 여전히 ​​동일해야합니다. 게시물의 질문에 답하려면 어떻게해야합니까? 이 메시지를 Outlook 및 iOS와 호환 가능하게 만드시겠습니까?) : MIME 메시지에 저장된 이벤트 정보가 포함 된 메시지를 보내야합니다.이 예가 mailgun-js 추가 정보 : https://github.com/bojand에 있습니다./mailgun-js # sending-mime-messages. 메일 구성 라이브러리 th ey 참조는 대안 (https://nodemailer.com/message/alternatives/)을 지원하고 iCal 이벤트 (https://nodemailer.com/message/calendar-events/)에 대한 특정 속성을 가지고 있습니다. –