Lotus Notes Mail-Funktion
25.08.2003 07:28:04
sergiesam
Hi,
ich habs mal Serienmails per Access über Notes versendet. Habe hierzu diese Funktion verwendet. Unten findest du einen Testaufruf. Diesen musst du nur in eine Schleife mit deinen Infos einbauen.
lg aus Linz,
Sam
Sub SendeNotesMail(strSubject As String, strSendTo As String, strBriefanrede As String, strBodyText As String, Optional strPathname)
Dim strCopyto As String
Dim strBlindCopyto As String
Dim strServer As String
Dim session
Set session = CreateObject("notes.NotesSession")
Dim obj
Dim rtItem
Dim docMail 'This will return the server and path to the current users mail file.
Dim db
Dim s
Set s = CreateObject("Notes.Notessession") 'New doesn't work here for some reason
Set db = s.GETDATABASE("", "")
'Creates a new document in the Mail Database
db.OPENMAIL
Set docMail = db.CREATEDOCUMENT 'When creating documents via VB the default values are not calculated so all the fields required 'must be set programmatically
Call docMail.REPLACEITEMVALUE("Form", "Memo")
strCopyto = "" 'Who to send a copy to
strBlindCopyto = "" 'Who you want to be blind copied to
Call docMail.REPLACEITEMVALUE("Subject", strSubject)
Call docMail.REPLACEITEMVALUE("SendTo", strSendTo)
Call docMail.REPLACEITEMVALUE("strCopyTo", strCopyto)
Call docMail.REPLACEITEMVALUE("BlindCopyTo", strBlindCopyto)
'Creates the memo body field, which contains main info and attachments
Set rtItem = docMail.CREATERICHTEXTITEM("Body")
Call rtItem.APPENDTEXT(strBriefanrede) ' Add some text to the body field
Call rtItem.ADDNEWLINE(2) ' Adds 2 blank lines to the body field
Call rtItem.APPENDTEXT(strBodyText)
Call rtItem.ADDNEWLINE(2)
'Embeds the file with the pathname stored in strpathname
If Not IsMissing(strPathname) Then Set obj = rtItem.EMBEDOBJECT(1454, "", strPathname)
Call rtItem.ADDNEWLINE(2) ' Adds 2 blank lines to the body field
Call rtItem.APPENDTEXT("Mit freundlichen Grüßen, ")
Call rtItem.ADDNEWLINE(1)
Call rtItem.APPENDTEXT("Dein Name")
'Call docMail.SEND(False) 'Don't include this to save it in the drafts view '
Call docMail.Save(True, True) 'Include this to save in the send view
End Sub
Sub test()
SendeNotesMail "Mein Betreff", "Test@test.com", "Sehr geehrter Herr Test", "Das ist mein Text", "C:\Config.sys"
End Sub