通过Swift中的共享UIActivityViewController在电子邮件中添加主题

时间:2017-01-17 11:22:27

标签: ios swift

我使用UIActivityViewController来共享数据。

我的代码:

textView.setText(String.valueOf(value));

我可以显示短信,电子邮件和备注,我可以在短信,电子邮件和备注中添加正文。但我对电子邮件有疑问:我只在电子邮件中添加正文,但我也想为电子邮件添加主题。我怎么能这样做?

3 个答案:

答案 0 :(得分:8)

只需将标题的值设置为您的标题:

activityViewController.setValue("This is my title", forKey: "Subject")

答案 1 :(得分:0)

尝试一下:

Sub Click(Source As Button)

    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Set uidoc = ws.CurrentDocument
    Set doc = uidoc.Document
    Call doc.RemoveItem("$KeepPrivate")
    Call doc.Save(True,True)
    doc.SaveOptions = "0"
    Call uidoc.Close
    Set uidoc = ws.EditDocument(True,doc,False) 
    Call uidoc.Print
    Dim item As New NotesItem(doc,"$KeepPrivate","1")
    Call uidoc.Save
    Call doc.Save(True,True)
    doc.SaveOptions = "0"

End Sub

答案 2 :(得分:0)

使用此行代码在邮件中添加主题,但这会将主题添加到默认的iOS邮件中,而不是在Google邮件中。

let string : String = "Hello this is content to Body of my mail."

let activityViewController = UIActivityViewController(activityItems: [string], applicationActivities: nil)

activityViewController.setValue("Subject Title",forkey "subject")

// This line of code will support alertcontroller as popover for iPAd also.                   
 if let popoverController = activityViewController.popoverPresentationController {
           popoverController.sourceView = super.view  
}

navigationController?.present(activityViewController, animated: true){
                 }