KDC900
06-01-2018, 10:12 AM
Hello,
I am trying to create a button that when pressed will ask for a due date from the user, select the email list of recipients from a query and set the ".Bcc" option equal to the email list. I have created the input box that ask for due date and I have created the email code that creates the email, but I am having trouble with selecting the Email Address from the query and setting the ".Bcc" option equal to it. below is the code I have now any help will be appreciated, i have looked around and haven't had luck fixing it.
Private Sub Command234_Click()
'Input Msg Box asking for Due date
Dim strInput As String
Dim strMsg As String
strMsg = "Enter pick up time"
strInput = InputBox(Prompt:=strMsg, Title:="Info Needed")
'If user does not enter anything
If strInput = "" Then
MsgBox "Please fill in the input box before sending an email.", vbCritical + vbOKOnly, "Input Box is Blank"
'If user enters any thing
Else
' Sql Select to pull list of emails form a Query
Dim qrystr1 As String
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
qrystr1 = "SELECT Eamil FROM Email_1 WHERE Entry_Table.[Bidder#] = Winner_Pick.[Bidder Number]"
Set rs = db.OpenRecordset(qrystr1)
End If
' to generate Email
Dim oLook As Object
Dim oMail As Object
Dim str As String
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
' Set ".to" equal to Results from select
With oMail
.To = "this will be set to a general email"
.Bcc = qrystr1
.Subject = "Action Winner"
.Body = "Congratulations!!" & vbNewLine & vbNewLine & "You have won an item(s) in [Events Name], you have until" & " " & strInput & " " & "to pick up your item or it will be offered to the next bidder." & vbNewLine & vbNewLine & vbNewLine & "Thank You," & vbNewLine & "Human Resources Department"
.Display
End With
Set oMail = Nothing
Set oLook = Nothing
rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub
I am trying to create a button that when pressed will ask for a due date from the user, select the email list of recipients from a query and set the ".Bcc" option equal to the email list. I have created the input box that ask for due date and I have created the email code that creates the email, but I am having trouble with selecting the Email Address from the query and setting the ".Bcc" option equal to it. below is the code I have now any help will be appreciated, i have looked around and haven't had luck fixing it.
Private Sub Command234_Click()
'Input Msg Box asking for Due date
Dim strInput As String
Dim strMsg As String
strMsg = "Enter pick up time"
strInput = InputBox(Prompt:=strMsg, Title:="Info Needed")
'If user does not enter anything
If strInput = "" Then
MsgBox "Please fill in the input box before sending an email.", vbCritical + vbOKOnly, "Input Box is Blank"
'If user enters any thing
Else
' Sql Select to pull list of emails form a Query
Dim qrystr1 As String
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
qrystr1 = "SELECT Eamil FROM Email_1 WHERE Entry_Table.[Bidder#] = Winner_Pick.[Bidder Number]"
Set rs = db.OpenRecordset(qrystr1)
End If
' to generate Email
Dim oLook As Object
Dim oMail As Object
Dim str As String
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
' Set ".to" equal to Results from select
With oMail
.To = "this will be set to a general email"
.Bcc = qrystr1
.Subject = "Action Winner"
.Body = "Congratulations!!" & vbNewLine & vbNewLine & "You have won an item(s) in [Events Name], you have until" & " " & strInput & " " & "to pick up your item or it will be offered to the next bidder." & vbNewLine & vbNewLine & vbNewLine & "Thank You," & vbNewLine & "Human Resources Department"
.Display
End With
Set oMail = Nothing
Set oLook = Nothing
rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub