Corona lua:如何将保存到系统目录的数据文件附加到电子邮件中?我构建后,在iPad上弹出的电子邮件中会显示data.txt文件的图像,但是尽管发送了电子邮件,但仍未附加。图像很好。我使用“text”,“plain”和“text / plain”作为mime类型。如果你能帮忙解决这个问题,我将不胜感激!
答案 0 :(得分:1)
试试这个:
-----------------------------------------------------------------------------------
-- Creating the text file --
-----------------------------------------------------------------------------------
local filePath_Type = system.pathForFile( "myTextFile.txt", system.DocumentsDirectory )
local file = io.open( filePath_Type, "r" )
if file then
io.close( file )
else
--Create an empty file--
local path_Type = system.pathForFile( "myTextFile.txt", system.DocumentsDirectory )
local file = io.open( path_Type, "w+b" )
file:write("My data inside file")
io.close( file )
end
-----------------------------------------------------------------------------------
-- Now, to email this file --
-----------------------------------------------------------------------------------
function showMailPicker()
-- Create mail options --
local options =
{
to = { "me@me.com",},
subject = "Subject Text",
body = "Email Body",
attachment =
{
{ baseDir=system.DocumentsDirectory, filename="myTextFile.txt", type="text" },
},
}
-- Send mail --
native.showPopup("mail", options)
end
submitButton = display.newImageRect("myButton.png",100,40)
submitButton.x = 160
submitButton.y = 240
submitButton:addEventListener("tap",showMailPicker)
保持编码..............:)