A
awrex
Please help!
I have a couple of scripts that I'm trying to get to work with each other
and I'm not having much success....
I have a form that I have a submit button that I would like the form to do a
"Save As" then send via Lotus Notes. I have the Lotus Notes script and the
Save As script, but not a clue as to how to get them to work with one
another....
I've commented out some things in a trial and error method... YOUR HELP IS
APPRECIATED!!!
Sub CTRL163_5_OnClick(eventObj)
'Save as dialog
Set obDialog = CreateObject("SAFRCFileDlg.FileSave")
objDialog.FileName = "C:\CPD PSR MMMMDDYY.xml"
objDialogFileType = "Infopath Form"
intReturn = objDialog.OpenFileSacDlg
If intReturn then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile
objFile.WriteLine Date
objFile.Close
'Else
' Wscript.Quit
End if
'Dim domSession As New NotesSession
on error resume next
Dim strFormName
strFormName = objDialog.FileName ' "CPD PSR Form.XML"
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
If Len(FSO.GetFile("C:\" & strFormName)) > 0 Then
FSO.DeleteFile "c:\" & strFormName
End If
on error goto 0
Dim domSession
Set domSession = CreateObject("Lotus.NotesSession")
Dim domNotesDatabaseMailFile
Dim domNotesDocumentMemo
Dim domNotesRichTextItemBody
' Put your password in the quotes below to skip prompting
domSession.Initialize ""
Dim dbdir
Set dbdir = domSession.GetDbDirectory("")
Set domNotesDatabaseMailFile = dbdir.OpenMailDatabase
' Generate an error if previous attempts were unsuccessful.
If domNotesDatabaseMailFile Is Nothing Then
MsgBox "Mail file not open"
Exit Sub
End If
Dim SendToArray
SendToArray = "(e-mail address removed)"
' Create a new memo document.
Set domNotesDocumentMemo = domNotesDatabaseMailFile.CreateDocument
Call domNotesDocumentMemo.AppendItemValue("Form", "Memo")
Call domNotesDocumentMemo.AppendItemValue("From", domSession.CommonUserName)
Call domNotesDocumentMemo.AppendItemValue("SendTo", domSession.UserName)
'change sendto address or s.UserName
Call domNotesDocumentMemo.AppendItemValue("Subject", "From infopath")
Set domNotesRichTextItemBody =
domNotesDocumentMemo.CreateRichTextItem("Body")
domNotesRichTextItemBody.AppendText "This is a test"
' This is where you can add support for attachments.
XDocument.SaveAs "c:\" & strFormName
attachment1 = "C:\" & strFormName
'Call domNotesRichTextItemBody.EmbedObject(EMBED_ATTACHMENT, "",
attachment1) 'attaches the file to the body field
Call domNotesRichTextItemBody.EmbedObject(1454, "", attachment1)
'attaches the file to the body field
Call domNotesDocumentMemo.Save(True, False)
' Send the document.
domNotesDocumentMemo.Send False
'MsgBox "Mail Sent with Attachment " & attachment1
Exit Sub
End Sub
I have a couple of scripts that I'm trying to get to work with each other
and I'm not having much success....
I have a form that I have a submit button that I would like the form to do a
"Save As" then send via Lotus Notes. I have the Lotus Notes script and the
Save As script, but not a clue as to how to get them to work with one
another....
I've commented out some things in a trial and error method... YOUR HELP IS
APPRECIATED!!!
Sub CTRL163_5_OnClick(eventObj)
'Save as dialog
Set obDialog = CreateObject("SAFRCFileDlg.FileSave")
objDialog.FileName = "C:\CPD PSR MMMMDDYY.xml"
objDialogFileType = "Infopath Form"
intReturn = objDialog.OpenFileSacDlg
If intReturn then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile
objFile.WriteLine Date
objFile.Close
'Else
' Wscript.Quit
End if
'Dim domSession As New NotesSession
on error resume next
Dim strFormName
strFormName = objDialog.FileName ' "CPD PSR Form.XML"
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
If Len(FSO.GetFile("C:\" & strFormName)) > 0 Then
FSO.DeleteFile "c:\" & strFormName
End If
on error goto 0
Dim domSession
Set domSession = CreateObject("Lotus.NotesSession")
Dim domNotesDatabaseMailFile
Dim domNotesDocumentMemo
Dim domNotesRichTextItemBody
' Put your password in the quotes below to skip prompting
domSession.Initialize ""
Dim dbdir
Set dbdir = domSession.GetDbDirectory("")
Set domNotesDatabaseMailFile = dbdir.OpenMailDatabase
' Generate an error if previous attempts were unsuccessful.
If domNotesDatabaseMailFile Is Nothing Then
MsgBox "Mail file not open"
Exit Sub
End If
Dim SendToArray
SendToArray = "(e-mail address removed)"
' Create a new memo document.
Set domNotesDocumentMemo = domNotesDatabaseMailFile.CreateDocument
Call domNotesDocumentMemo.AppendItemValue("Form", "Memo")
Call domNotesDocumentMemo.AppendItemValue("From", domSession.CommonUserName)
Call domNotesDocumentMemo.AppendItemValue("SendTo", domSession.UserName)
'change sendto address or s.UserName
Call domNotesDocumentMemo.AppendItemValue("Subject", "From infopath")
Set domNotesRichTextItemBody =
domNotesDocumentMemo.CreateRichTextItem("Body")
domNotesRichTextItemBody.AppendText "This is a test"
' This is where you can add support for attachments.
XDocument.SaveAs "c:\" & strFormName
attachment1 = "C:\" & strFormName
'Call domNotesRichTextItemBody.EmbedObject(EMBED_ATTACHMENT, "",
attachment1) 'attaches the file to the body field
Call domNotesRichTextItemBody.EmbedObject(1454, "", attachment1)
'attaches the file to the body field
Call domNotesDocumentMemo.Save(True, False)
' Send the document.
domNotesDocumentMemo.Send False
'MsgBox "Mail Sent with Attachment " & attachment1
Exit Sub
End Sub