# BeforeAction in "Send Mail" action

**URL:** https://www.finalbuilder.com/forums/t/beforeaction-in-send-mail-action/1837
**Category:** Discussion
**Created:** [August 23, 2011, 8:05am UTC](https://www.finalbuilder.com/forums/t/beforeaction-in-send-mail-action/1837 "2011-08-23T08:05:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![crilando](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/c/ea5d25/32.png) [@crilando](https://www.finalbuilder.com/forums/u/crilando)
#### Post date: [August 23, 2011, 8:05am UTC](https://www.finalbuilder.com/forums/t/beforeaction-in-send-mail-action/1837/1 "2011-08-23T08:05:01Z")

</div>

Hello,

i want to load the email recipientList from our newsletter server wit ADO from a MSSQL database. At first i am trying how to set the email list programmaticly but the list is ignored by the action.

i have made the following:

```
**Sub BeforeAction(Action, SkipAction)** Action.RecipientsList.Add "info",info@oneDomain.dcom, true
   Action.RecipientsList.Add "support","[support@AnotherDomain.com](mailto:support@AnotherDomain.com)", true
```

```
**End sub**
```

&nbsp;

What do i have to change?

Thank you  
chris

---

<div class="post-metadata">

### Author: ![crilando](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/c/ea5d25/32.png) [@crilando](https://www.finalbuilder.com/forums/u/crilando)
#### Post date: [August 23, 2011, 11:49am UTC](https://www.finalbuilder.com/forums/t/beforeaction-in-send-mail-action/1837/2 "2011-08-23T11:49:44Z")

</div>

```
Hi,after restart all was working.So this track can be closed.I have also enhanced this part with direct access to a microosft sql server with ado recordset. For all who are interested here the code, which uses integrated securitry. Servername, Instancename (if yu have one, otherwise leave also the backslash) etc, must be changed with real names:**Sub BeforeAction(Action, SkipAction)** dim con, rs
Set con = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
con.open _
"Provider=SQLOLEDB;Data Source=_ServerName_\_InstanceNam_e;" & _
"Trusted_Connection=Yes;Initial Catalog=_MyDatabase_;"
rs.open "SELECT_Fullname_,_Email_ FROM_MyAddressTable_", con
do while not rs.eof
Action.RecipientsList.Add CStr(rs.fields("_Fullname_")),CStr(rs.fields("_Email_")), true
rs.movenext
loop
set con = nothing
set rs = nothing
**End Sub**
```
