G
Gntlhnds
I have code designed by Ron Huges attached to a button that will generate an
addressed e-mail from addresses in a table. What I would like to do is be
able to create a second table where e-mail addresses are manually put in that
it can get addresses from as well (the first table is automatically created
by a make table query). I would also like to be able to create a signature
block or get it to use the default signature block selected in Outlook. Here
is the code:
Private Sub Command1_Click()
On Error GoTo ErrHandle
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strAddress As String 'this creates the Email addresses
Dim strTo As String 'this is needed to populate the TO block on
the EMail form
Dim strCC As String 'this is needed to populate the CC block on
the EMail form
Dim strBCC As String 'this is needed to populate the BCC block on
the EMail form
Dim strSubj As String 'this is needed to populate the SUBJ block on
the EMail form
Dim strText As String 'this is needed to populate a portion of the
message text block
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblemailtable", dbOpenSnapshot)
If rst.BOF = True And rst.EOF = True Then
MsgBox "There must be an error in the query as there are no EMail
Addresses listed!"
GoTo ErrExit
End If
With rst
.MoveFirst 'go to the first record
strAddress = .Fields("EmailName").Value
strTo = strAddress
.MoveNext 'get all subsequent addresses and separate each with a
semi-colon
Do While .EOF = False
strAddress = .Fields("EmailName").Value
strTo = strTo & "; " & strAddress
.MoveNext
Loop
End With
strTo = strTo
strCC = ""
strBCC = ""
strSubj = "Volunteer Opportunities"
'This will input a generic subject for your EMail. If you don't
'want a generic subject, just use the quotes, with nothing between them
strText = Chr$(13) & Chr$(13) & "" & Chr$(13) & ""
'Chr$(13) will insert a blank line in the subject of your EMail.
'Anything between the quotes will be inserted. You can edit, as
required before sending
'If you want the subject to be blank, just put the quotes, with nothing
between them
DoCmd.SendObject acSendNoObject, , , strTo, , strBCC, strSubj, strText,
True
'Note the above order. This code fills in the TO, BCC, Subj, and Text
blocks of the EMail form
ErrExit:
Exit Sub
ErrHandle:
MsgBox Err.Description
Resume ErrExit
Resume
End Sub
addressed e-mail from addresses in a table. What I would like to do is be
able to create a second table where e-mail addresses are manually put in that
it can get addresses from as well (the first table is automatically created
by a make table query). I would also like to be able to create a signature
block or get it to use the default signature block selected in Outlook. Here
is the code:
Private Sub Command1_Click()
On Error GoTo ErrHandle
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strAddress As String 'this creates the Email addresses
Dim strTo As String 'this is needed to populate the TO block on
the EMail form
Dim strCC As String 'this is needed to populate the CC block on
the EMail form
Dim strBCC As String 'this is needed to populate the BCC block on
the EMail form
Dim strSubj As String 'this is needed to populate the SUBJ block on
the EMail form
Dim strText As String 'this is needed to populate a portion of the
message text block
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblemailtable", dbOpenSnapshot)
If rst.BOF = True And rst.EOF = True Then
MsgBox "There must be an error in the query as there are no EMail
Addresses listed!"
GoTo ErrExit
End If
With rst
.MoveFirst 'go to the first record
strAddress = .Fields("EmailName").Value
strTo = strAddress
.MoveNext 'get all subsequent addresses and separate each with a
semi-colon
Do While .EOF = False
strAddress = .Fields("EmailName").Value
strTo = strTo & "; " & strAddress
.MoveNext
Loop
End With
strTo = strTo
strCC = ""
strBCC = ""
strSubj = "Volunteer Opportunities"
'This will input a generic subject for your EMail. If you don't
'want a generic subject, just use the quotes, with nothing between them
strText = Chr$(13) & Chr$(13) & "" & Chr$(13) & ""
'Chr$(13) will insert a blank line in the subject of your EMail.
'Anything between the quotes will be inserted. You can edit, as
required before sending
'If you want the subject to be blank, just put the quotes, with nothing
between them
DoCmd.SendObject acSendNoObject, , , strTo, , strBCC, strSubj, strText,
True
'Note the above order. This code fills in the TO, BCC, Subj, and Text
blocks of the EMail form
ErrExit:
Exit Sub
ErrHandle:
MsgBox Err.Description
Resume ErrExit
Resume
End Sub