1

Corona lua:如何将保存到系统目录的数据文件附加到电子邮件中?在我构建后,data.txt 文件的图像显示在 iPad 上弹出的电子邮件中,但尽管发送了电子邮件,但没有附加。图像很好。我使用“text”、“plain”和“text/plain”作为 mime 类型。如果您能对此提供帮助,我将不胜感激!

4

1 回答 1

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)

继续编码........ :)

于 2013-08-23T05:23:28.207 回答