By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,162 Members | 992 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,162 IT Pros & Developers. It's quick & easy.

Sending e-mail with variables from a table

P: 80
I'm using access to read in data from several fields and send an e-mail. I can capture one of the fields in the file into a variable (full_link), but not the others. Whenever it hits the variable assignment line for the other fields, I get a "Method or Data Member not found" error. If I hard-code the other fields but still have the strFullLink variable, it works fine. What am I missing?

Private Sub Command0_Click()
Dim strToWhom As String
Dim strSubject As String
Dim strBody As String
Dim strMsgBody As String
Dim intSeeOutlook As Integer
Dim strFullLink As String

DoCmd.OpenTable "table_email"

strFullLink = Me.full_link
strToWhom = Me.mail_add
strSubject = Me.mail_sub
'strToWhom = InputBox("Enter recipient's e-mail address.")
'strSubject = InputBox("Enter Subject.")
strBody = "Your package has been sent. It may be tracked with the following link: " + strFullLink

DoCmd.SendObject , , , strToWhom, , , strSubject, strBody, intSeeOutlook
x = MsgBox("Email has been sent")

End Sub
Aug 15 '07 #1
Share this Question
Share on Google+
3 Replies


P: 80
Okay, solved that one. All I had to do was remove the data source (which did not have those fields when I linked it to the table) and re-add it.
Aug 15 '07 #2

P: 80
Okay, new problem. I'm looping through the table to grab information and send an e-mail to each. However, the variables are not being re-set. The e-mail is being sent each time, but it's all the information from the first record. I know it's getting all the way through the loop, so why are the variables not reset to the next record's value?

Private Sub Command0_Click()
Dim intCounter As Integer
Dim strToWhom As String
Dim strSubject As String
Dim strBody As String
Dim strMsgBody As String
Dim intSeeOutlook As Integer
Dim strFullLink As String

DoCmd.OpenTable "table_email"
intCounter = 0

Do While intCounter < 10

strFullLink = Me.full_link
strToWhom = Me.mail_add
strSubject = Me.mail_sub
'strToWhom = InputBox("Enter recipient's e-mail address.")
'strSubject = InputBox("Enter Subject.")
strBody = "Your package has been sent. It may be tracked with the following link: " + strFullLink

DoCmd.SendObject , , , strToWhom, , , strSubject, strBody, intSeeOutlook
'x = MsgBox("Email has been sent")
DoCmd.GoToRecord , , acNext
intCounter = intCounter + 1
Loop

End Sub
Aug 15 '07 #3

FishVal
Expert 2.5K+
P: 2,653
Okay, new problem. I'm looping through the table to grab information and send an e-mail to each. However, the variables are not being re-set. The e-mail is being sent each time, but it's all the information from the first record. I know it's getting all the way through the loop, so why are the variables not reset to the next record's value?

Private Sub Command0_Click()
Dim intCounter As Integer
Dim strToWhom As String
Dim strSubject As String
Dim strBody As String
Dim strMsgBody As String
Dim intSeeOutlook As Integer
Dim strFullLink As String

DoCmd.OpenTable "table_email"
intCounter = 0

Do While intCounter < 10

strFullLink = Me.full_link
strToWhom = Me.mail_add
strSubject = Me.mail_sub
'strToWhom = InputBox("Enter recipient's e-mail address.")
'strSubject = InputBox("Enter Subject.")
strBody = "Your package has been sent. It may be tracked with the following link: " + strFullLink

DoCmd.SendObject , , , strToWhom, , , strSubject, strBody, intSeeOutlook
'x = MsgBox("Email has been sent")
DoCmd.GoToRecord , , acNext
intCounter = intCounter + 1
Loop

End Sub
Hi, there.
Pay attention to your code.
Your open a table
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenTable "table_email"
and loop through its records
Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acNext
but gather data from a form where CommandButton is located.
Expand|Select|Wrap|Line Numbers
  1.     strFullLink = Me.full_link
  2.     strToWhom = Me.mail_add
  3.     strSubject = Me.mail_sub
  4.  
Aug 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.