NACHTRAG: Ergänzt um Betriebssystem-Unabhängigkeit (Windows Linux)
Sub MailVersand
Dim mTo as String
Dim mSubject as String
Dim mCC() as String
Dim mBCC() as String
Dim mAttachement() as String
Dim mBody as String
Dim oMailAgent as Object
Dim oMailClient as Object
Dim oMailMessage as Object
mTo = "HansWernerHerold@t-online.de"
mSubject = " Test, Test, Test ..."
mCC = Array("OoOHWHOoO@t-online.de","HansWernerHerold@t-online.de")
mBCC = Array("OoOHWHOoO@t-online.de","HansWernerHerold@t-online.de")
mAttachement = Array(ConvertToUrl("E:\TMP\WRITER.odt"),ConvertToUrl("E:\TMP\CALC.ods"))
mBody = "hallo, hallo" & Chr(10) & "Und, tschüss" & Chr(10) & "PS:"
Select Case GetGUIType()
Case 1 ' Windows
oMailAgent = createUnoService("com.sun.star.system.SimpleSystemMail")
Case 4 ' Linux
oMailAgent = CreateUnoService("com.sun.star.system.SimpleCommandMail")
Case Else ' Betriebssysten unbekannt
MsgBox("Das Betriebssystem ist weder Windows noch Linux !")
End
End Select
oMailClient = oMailAgent.querySimpleMailClient()
oMailMessage = oMailClient.createSimpleMailMessage()
oMailMessage.setRecipient(mTo)
oMailMessage.setCcRecipient(mCC)
oMailMessage.setBccRecipient(mBCC)
oMailMessage.setSubject(mSubject)
oMailMessage.setAttachement(mAttachement)
oMailmessage.Body = mBody
oMailClient.sendSimpleMailMessage(oMailMessage,0)
End Sub