2016-08-24 36 views
2

我目前正試圖通過我的反應原生應用程序發送來自用戶設備的電子郵件。 這樣做的過程很簡單。用戶填寫一些輸入字段,選擇一張圖片(新的或來自圖庫)並繼續通過電子郵件發送。 根據模塊的文檔,圖片的絕對文件路徑是必需的。反應本地梅勒(RNMail) - 問題與附加文件

這是我得到的外觀如下文件路徑:

file:///Users/User/Library/Developer/CoreSimulator/Devices/909705DC-D5…119-75CC009FFA5C/Documents/images/6EC7EAA7-0D37-4909-ABC4-B5DE250ED968.jpg 

我也得到了以下錯誤消息:

Exception '-[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:] attachment must not be nil.' was thrown while invoking mail on target RNMail with params (
     { 
     attachment =   { 
      name = Name; 
      path = "file:///Users/zser/Library/Developer/CoreSimulator/Devices/909705DC-D5…119-75CC009FFA5C/Documents/images/6EC7EAA7-0D37-4909-ABC4-B5DE250ED968.jpg"; 
      type = jpg; 
     }; 
     body = "<h1>Content</h1>"; 
     isHTML = 1; 
     recipients =   (
      "[email protected]" 
     ); 
     subject = subject; 
    }, 
    25 
) 

什麼不對的這條道路?

繼承人的基本代碼,應該接受該文件作爲attachement:

Mailer.mail({ 
     subject: 'Subject', 
     recipients: ['[email protected]'], 
     body: `<h1>Content</h1>`, 
     isHTML: true, // iOS only, exclude if false 
     attachment: { 
     path: that.state.absolute_path, // The absolute path of the file from which to read data. 
     type: 'jpg', // Mime Type: jpg, png, doc, ppt, html, pdf 
     name: 'Ladunek', // Optional: Custom filename for attachment 
     } 
    }, (error, event) => { 
     if(error) { 
      AlertIOS.alert('Error', 'Niestety mail nie zostal wyslany. Prosze przeslac manualnie mail na : [email protected]'); 
     } 
    }) 

謝謝您的幫助

回答

0

顯然是從絕對路徑移除'file:///'固定的問題。