All works well, but I should now like to add a 'group' email button which will send the email to a group/list of email addresses. So I want to:
1. SQL select the email addresses from the main table for those belong to group 'XXX'
2. In the line 'MailMessage.setRecipient(mTo)' below, I want mTo to be the list of email addresses selected.
Does anyone have any suggestions how best to do this?
Regards
Nocton
Code: Select all
Sub openEmailClient(Event As Object)
On Error Goto HandleError
' code bound to 'Mouse Button Pressed' of a Text Box
Dim MailClient, MailAgent,MailMessage As Object
Dim frm, mTo As String
Dim UI As Integer
frm=ThisComponent.Drawpage.Forms.getByName("MembersForm")
mTo = frm.getByName("txtEmailAddress").currentvalue
If mTo="" Then
Exit Sub 'NO EMAIL ADDRESS
End If
MailAgent=CreateUnoService("com.sun.star.system.SimpleSystemMail")
MailClient=MailAgent.querySimpleMailClient()
MailMessage=MailClient.createSimpleMailMessage()
MailMessage.setRecipient(mTo)
UI=0
' the UI flag indicates if the mail client user interface is to be opened (0) or sent
' w/o opening (1). If you select 1, your email client may open a confirmation box
' indicating someone is trying to send an email--sometimes it is not the top most window.
' if nothing seems to happen, your email client may be waiting for you to respond you can
' set your email client to always allow an application to send emails - but may be a security issue
MailClient.sendSimpleMailMessage(MailMessage, UI)
HandleError:
If err<>0 Then
Exit Sub
End If
End Sub