I have code that attaches a file and a body to a new email and sends it and then closes the email. The issue is, I get a HCI pop up box saying 'Do you want to save this new document?' when the sent email is closed. I have been trying to find some info about this but I haven't been able to find anything regarding parsing an answer to select 'No' on the pop up box?
Any links or guidance would be greatly appreciated, I have included my sending code for context.
Public Sub LN_Send_Email()
Const EMBED_ATTACHMENT As Long = 1454
Dim Notes As Object
Dim Workspace As Object
Dim UIdoc As Object
Dim Attachment As Object
Dim Data As String
Dim attachmentFile As String
Dim File As String
Dim i As Long
Dim Row As Long
Dim Recipient As String
Dim Doc As Object
Row = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To Row
Recipient = Worksheets("Sheet1").Range("B" & i)
If Recipient <> "" Then
File = Worksheets("Sheet1").Range("A" & i).Value
attachmentFile = "Directory\" & File
Data = Format(Now(), "dd/mm/yyyy")
Set Notes = CreateObject("Notes.NotesSession")
Set Workspace = CreateObject("Notes.NotesUIWorkspace")
Workspace.ComposeDocument , , "Memo"
Set UIdoc = Workspace.CurrentDocument
Set Doc = UIdoc.Document
With UIdoc
.FieldSetText "EnterSendTo", Recipient
.FieldSetText "Subject", "Subject " & Data
.GotoField "Body"
.Import "HTML File", "Directory"
If attachmentFile <> "" Then
If Dir(attachmentFile) <> "" Then
Set Attachment = .Document.CreateRichTextItem("Attachment")
.InsertText String(2, vbLf) & "File attached: " & Mid(attachmentFile, InStrRev(attachmentFile, "\") 1)
Attachment.EmbedObject EMBED_ATTACHMENT, "", attachmentFile
Else
MsgBox "File " & attachmentFile & " not found, so not attached to email."
End If
End If
Application.CutCopyMode = False
.Send
.Close
Application.Wait Now TimeValue("00:00:02")
End With
Set UIdoc = Nothing
Set Workspace = Nothing
Set Notes = Nothing
End If
Next i
End Sub
CodePudding user response:
Try setting
doc.SaveOptions = "0"
before you send the document. This flag tells the client to not prompt to save the mail document.
If this doesn't work, you may need to use the doc (NotesDocument class) rather than the UIDoc (NotesUIDocument class) to create and send the mail.