473,388 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Need VBA for sending email from query result by recordset

http://bytes.com/topic/access/answer...il-based-query

Best example is from the link above however, I need it to be modified.

Basically, I have a query with many fields. 3 fields are email address where I needs to send emails our grouping records as attachment or part of the body in the email detailing transactions. The query is for delinquent payments.

Requirement:
3 fields = Email, Del Email, Bur Email
I need the recordsets with to be grouped by those 3 fields and an email sent. So for example under 1-10 records with email 1@1.com i click a button and an email will be sent to 1@1.com then moves to another email address grouping the recordset with that criteria then loop.

the second button with 2@2.com in [del email] field will send all recordset grouping transaction inside that query and adding it in the body or template from text box then loop. and same goes for bur email.

I hope this is clear.

Also, I would like to upload or paste a template in a textbox to be used so no added fields needed to be created to limit the size of the db.

I've attached a sample with dummy data on query and a sample result however it will be looped to email the rest of the records based on grouped column.

Could someone please help? I feel like this is out of my skill level.

thank you!
Attached Files
File Type: zip Sample.zip (61.5 KB, 359 views)
Nov 25 '14 #1

✓ answered by aflores41

Twinn,

I got your code to work. Thank you so much! Just needed to modify the query.

This inquiry is now closed! See complete code below.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT23_ReportEmail()
  2. Dim OlApp As Object
  3. Dim OlMail As Object
  4. Dim olMailItem As Integer
  5. Dim db As DAO.Database
  6. Dim rst1 As DAO.Recordset
  7. Dim rst2 As DAO.Recordset
  8. Dim strBody As String
  9. Dim strSQL As String
  10.  
  11. Set OlApp = CreateObject("Outlook.Application")
  12. Set db = CurrentDb
  13. Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  14.  
  15. If Not rst1.RecordCount = 0 Then
  16. rst1.MoveFirst
  17. Do While Not rst1.EOF
  18. Set OlMail = OlApp.CreateItem(olMailItem)
  19. OlMail.To = rst1!Email
  20. OlMail.Subject = "This is the Subject of Your E-Mail!"
  21. strBody = "Dear " & "," & Chr(10) & Chr(10) & _
  22. "Hello Person!  I am greeting you!" & vbCrLf & vbCrLf & _
  23. "This is the e-mail Body -- finish it please!" & vbCrLf & vbCrLf
  24. strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  25.  
  26. Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  27. If Not rst2.RecordCount = 0 Then
  28. rst2.MoveFirst
  29. Do While Not rst2.EOF
  30. strBody = strBody & rst2![expr1] & vbCrLf & vbCrLf
  31. 'strBody = strBody & rst2![Emaila]
  32. rst2.MoveNext
  33. Loop
  34. End If
  35. rst2.Close
  36. Set rst2 = Nothing
  37.  
  38. OlMail.Body = strBody
  39. OlMail.Display
  40. 'Send your e-mail here
  41. rst1.MoveNext
  42. Loop
  43. End If
  44. rst1.Close
  45. db.Close
  46. Set rst1 = Nothing
  47. Set db = Nothing
  48. End Function
  49.  
  50.  
  51.  

44 10893
twinnyfo
3,653 Expert Mod 2GB
aflores41,

We typically don't write your code for you. You must make a valid attempt at working through this and we will be glad to assist and trouble shoot.

Additionally, I think I might understand what you want to do, but it is unclear. I also definitely do not understand what you mean by:

Also, I would like to upload or paste a template in a textbox to be used so no added fields needed to be created to limit the size of the db.
You may have to explain that one a little better.
Nov 26 '14 #2
I meant to either paste an email template (e.g. The card information is below: _field__ , field, field, . Please pay the amount field, field.

The concept is similar to mail merge when using word and outlook. So it's either uploading an oft (outlook template file) as template or pasting it in a text box.

I was working on different codes actually and none of them works. See below.

This code is for the browse button to use .oft file as template then loop to send email:

Expand|Select|Wrap|Line Numbers
  1. Dim ahtFilter As String
  2.   Dim ahtExtension As String
  3.   Dim ahtFileName As String
  4.  
  5.  
  6.   ahtFilter = "Outlook Template files (*.OFT)"
  7.   ahtExtension = "*.OFT"
  8.   ahtFileName = "*.OFT"
  9.  
  10.   Me.txt_email = OpenFile(Me.txtDir, Me.txtZipFileName1, ahtFilter, ahtExtension, ahtFileName)
  11.  
  12.  
  13. The browse vba came with a public function in module:
  14.  
  15. Public Function OpenFile _
  16. (Optional varDirectory As Object, _
  17.  Optional MyFileName As Object, _
  18.  Optional ahtFilter As String, _
  19.  Optional ahtExtension As String, _
  20.  Optional ahtFileName As String) As Variant
  21.  
  22.  
  23.     Dim strFilter As String
  24.     Dim lngFlags As Long
  25.     Dim varFileName As Variant
  26.     Dim curr_year As String
  27.     Dim filename As String
  28.  
  29.     lngFlags = ahtOFN_FILEMUSTEXIST Or ahtOFN_HIDEREADONLY Or ahtOFN_NOCHANGEDIR
  30.  
  31. '''''    If IsMissing(varDirectory) Or IsNull(varDirectory) Then
  32. '''''        varDirectory = Me.DbDir & "\Imports\"
  33. '''''    End If
  34.  
  35.  
  36. ' you can choose to add a number of file extensions which will appear in the drop down Files of Type box
  37. strFilter = ahtAddFilterItem(strFilter, ahtFilter, ahtExtension)
  38. filename = varDirectory & ahtFileName
  39. 'strFilter = ahtAddFilterItem(strFilter, "Any files (*.*)", "*.*")
  40. varFileName = ahtCommonFileOpenSave( _
  41. filename:=filename, _
  42. MyFileName:=MyFileName, _
  43. OpenFile:=True, _
  44. InitialDir:=varDirectory, _
  45. Filter:=strFilter, _
  46. Flags:=lngFlags, _
  47. DialogTitle:="Open an Outlook Template file ...") ' < This is the title to your dialog box
  48.  
  49.  
  50.  
  51. OpenFile = varFileName
  52.  
  53.  
  54.  
  55. End Function
  56.  
  57.  
  58. I also tried using the below vba however, it does not loop and there's an error when sending the message. I was also getting an error when using stremail as a source for email addresses. Typing in emails manual sends the email but defeats the purpose of sending it from a field.
  59.  
  60. Thank you very much!
  61.  
  62. Public Function CreateRIT_ReportEmail_works_but_not_complete()
  63. 'write the default Outlook contact name list to the active worksheet
  64. Dim rs As DAO.Recordset
  65. Dim OlApp As Object
  66. Dim OlMail As Object
  67. Dim ToRecipient As String
  68.  
  69.   Set OlApp = CreateObject("Outlook.Application")
  70.   Set OlMail = OlApp.CreateItem(olMailItem)
  71.  
  72.   Set rs = CurrentDb.OpenRecordset("email end of month")
  73.   With rs
  74.            Do Until rs.EOF
  75.             stremail = ![email]
  76.             strSubject = ![Hierarchy level 4]
  77.             strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  78.                       "  email message body goes here"
  79.  
  80.             '.Edit
  81.             'rs.Update
  82.  
  83.             'Set OutMail = OutApp.CreateItem(olMailItem)
  84.  
  85.             With OlMail
  86.               DoCmd.SetWarnings False
  87.                 .To = stremail
  88.                 .CC = ""
  89.                 .BCC = ""
  90.                 .Subject = strSubject
  91.                 .Body = strBody
  92.  
  93.                 '.SendUsingAccount = OutApp.Session.Accounts.Item(2)
  94.                 .Send
  95.                 DoCmd.SetWarnings True
  96.             End With
  97.  
  98.             .MoveNext
  99.         Loop
  100. End With
  101.  
  102.  
  103. End Function
Nov 26 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Please use Code Tags when including code. It is much easier for us to follow in that format.

You mention you receive several errors, but you do not mention what those errors are, or where they occur. It is impossible to help without that information.

Concerning the not looping to send multiple e-mails, I think you can start by setting your OLItem after you get into the Recordset.


Expand|Select|Wrap|Line Numbers
  1. Do Until rs.EOF
  2.     Set OlMail = OlApp.CreateItem(olMailItem)
  3.     stremail = ![email]
  4.     strSubject = ![Hierarchy level 4]
  5.     etc....
You set the object once and then send it. Once you send it, it doesn't really exist any more.

My DB sends tons of e-mail (via looping) and I never use any Templates, as I just create the body myself. I believe it is possible to create an HTML email body, but I have not had success with it, so I have not worked with it much.
Nov 26 '14 #4
Twinnyfo,

I apologize. I'm new with this site. For code below:
Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT_ReportEmail()
  2. 'write the default Outlook contact name list to the active worksheet
  3. Dim rs As DAO.Recordset
  4. Dim OlApp As Object
  5. Dim OlMail As Object
  6. Dim ToRecipient As String
  7.  
  8.   Set OlApp = CreateObject("Outlook.Application")
  9.   Set OlMail = OlApp.CreateItem(olMailItem)
  10.  
  11.   Set rs = CurrentDb.OpenRecordset("Email")
  12.   With rs
  13.            Do Until rs.EOF
  14.             stremail = ![email]
  15.             strSubject = ![Account Number (Short)]
  16.             strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  17.                       "  email message body goes here"
  18.  
  19.             '.Edit
  20.             'rs.Update
  21.  
  22.             'Set OutMail = OutApp.CreateItem(olMailItem)
  23.  
  24.             With OlMail
  25.               DoCmd.SetWarnings False
  26.                 .To = stremail
  27.                 .CC = ""
  28.                 .BCC = ""
  29.                 .Subject = strSubject
  30.                 .Body = strBody
  31.  
  32.                 '.SendUsingAccount = OutApp.Session.Accounts.Item(2)
  33.                 .Send
  34.                 DoCmd.SetWarnings True
  35.             End With
  36.  
  37.             .MoveNext
  38.         Loop
  39. End With
  40.  
  41.  
  42. End Function
It works sending out mail and the loop works too! thank you! I'm searching through online on how to get rid of the warning prompt as to allow sending out emails. Suggestions are welcome.

Also, do you have any suggestions on grouping the email sent based on data on fields? i.e. send email to af@af.com including all recordset associated with that email then next email is for mix@mix.com with all associated recordset.

I was thinking of making reports however; it defeats the purpose of the coding.. and the db will get bigger.

Thanks again!
Nov 26 '14 #5
Follow up.. work around to outlook warning prompt is..

Expand|Select|Wrap|Line Numbers
  1.             With OlMail
  2.                 .To = stremail
  3.                 .CC = ""
  4.                 .BCC = ""
  5.                 .Subject = strSubject
  6.                 .Body = strBody
  7.                 .Display
  8.  
  9.  
  10.                 '.SendUsingAccount = OutApp.Session.Accounts.Item(2)
  11.                 '.Send
  12.  
  13.             End With
  14.             SendKeys "%S"
  15.             .MoveNext
  16.         Loop
  17. End With
  18.  
Nov 26 '14 #6
twinnyfo
3,653 Expert Mod 2GB
aflores41,

Did this solution work for you? Any snags that you have run across?
Dec 1 '14 #7
The solution for sending emails works. Thanks! However, I need to modify the code to send emails enclosing group of transactions inside if it's going to one email address.

For now, the email is being sent to individual recordset. I wanted to use a "group by" when there are multiple recordset that's going to the same email address.

Do you have any suggestion into grouping these records into one when sending email?

Thanks.

-Aflores
Dec 1 '14 #8
twinnyfo
3,653 Expert Mod 2GB
Aflores,

I'm not sure I follow your question:

send emails enclosing group of transactions inside if it's going to one email address
and
I wanted to use a "group by" when there are multiple recordset that's going to the same email address.
If I do follow you correctly, you want:

I have a list of e-mail addresses and a list of e-mail bodies that must go out to these e-mail addresses. I have two separate e-mail bodies that are going to the same e-mail address, and I want to combine the two e-mail bodies into one, so that the recipient only receives one e-mail instead of two (or more).

Is that correct?
Dec 1 '14 #9
So basically, the macro written sends email to the addresses from a field. In the body of the email, if there are multiple records that could be grouped by one email address from the field, then it details the record information of how many number of records and send it into one email address. Same concept with group by.. send email to one address as group by but the records are in the body..


For example,

ax@ax.com

body:
record1
record2
record3
record4

ax2@ax2.com
body:
record5

ax3@ax3.com
body:
record6
record7
record8

-Aflores
Dec 1 '14 #10
twinnyfo
3,653 Expert Mod 2GB
Got it (I'm pretty sure). I use this same method all the time.

Concept: Create a recordset that generates your list of all e-mail Recipients. This recordset could be a query based on the current query, but only returns an aggregate query of the e-mail addresses. So, your first query/.recordset will return the following values:
ax@ax.com
ax2@ax2.com
ax3@ax3.com
NOT this:
ax@ax.com
ax@ax.com
ax@ax.com
ax@ax.com
ax2@ax2.com
ax3@ax3.com
ax3@ax3.com
ax3@ax3.com
Then, within your code, you nest another recordset that pulls all the information based on e-mail Address. Here, is what one of our experts here (Rabbit) likes to call "pseudo code":

Expand|Select|Wrap|Line Numbers
  1. Private Sub SendEmails()
  2.     'Declare your Variables
  3.     Set rst1 = 'gather your e-mail addresses
  4.     Do While Not rst1.EOF
  5.         Set rst2 = 'Your Other Query: WHERE EMailAddress = '" & rst1!EMailAddress & "';"
  6.         Do While Not rst2.EOF
  7.             'Build Your E-Mail Message
  8.             rst2.MoveNext
  9.         Loop
  10.         'Send your E-Mail
  11.         rst1.MoveNext
  12.     Loop
  13. End Sub
I hope this makes sense. let us know if you come across any hitches.
Dec 1 '14 #11
Okay, I understand what your saying and it makes sense however I don't think I'm able to merge the two codes.

See below for the codes I tried using but an error came out as:
Compile error: Method or data member not found.
- not sure how to add the third recordset.

Sample code:
Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT_ReportEmail()
  2. Dim rs As DAO.Recordset
  3. Dim rst1 As DAO.Recordset2
  4. Dim rst2 As DAO.Recordsets
  5.  
  6.     Set rst2 = CurrentDb.OpenRecordset("Email")
  7.     'rst1 is the distinct email addresses from rst2
  8.     Set rst1 = CurrentDb.OpenRecordset("distinct Email")
  9.     Do While Not rst1.EOF
  10.         Set rst2 = rst1
  11.         Do While Not rst2.EOF
  12.             'Build Your E-Mail Message
  13.             rst2.MoveNext
  14.         Loop
  15.           With rs
  16.            Do Until rs.EOF
  17.  
  18.             'OlSecurityManager.DisableOOMWarnings = True
  19.             Set OlMail = OlApp.CreateItem(olMailItem)
  20.             stremail = ![email]
  21.             strSubject = ![Account Number (Short)]
  22.             strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  23.                       "  email message body goes here"
  24.                 With OlMail
  25.                 .To = stremail
  26.                 .CC = ""
  27.                 .BCC = ""
  28.                 .Subject = strSubject
  29.                 .Body = strBody
  30.                 .Display
  31.  
  32.              End With
  33.              SendKeys "%S"
  34.                 .MoveNext
  35.             Loop
  36.             End With
  37.  
  38.         'Send your E-Mail
  39.         rst1.MoveNext
  40.     Loop
  41. End Function
  42.  
Thank you so much!

-aflores
Dec 1 '14 #12
twinnyfo
3,653 Expert Mod 2GB
Recommendations:

Line 1.5: It is a good practice to declare a db:

Expand|Select|Wrap|Line Numbers
  1. Dim db as DAO.Database
  2. then....
  3. Set rs = db OpenRecordset("EMail")
This allows you to refer to that db once when setting the recordsets--otherwise your system is using duplicate resources setting aside space for the same DB.

Line 3: declare it as a Recordset, not Recordset2.
Line 4: declare it as a Recordset, not Recordsets.

Lines 6ff: It is clear you did not understand the concept. I'm not al all clear what you were trying to do. Here is a go:

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT_ReportEmail()
  2.     Dim db As DAO.Database
  3.     Dim rst1 As DAO.Recordset
  4.     Dim rst2 As DAO.Recordset
  5.     Dim strSQL As String
  6.  
  7.     'rst1 is the distinct email addresses
  8.     Set rst1 = Db.OpenRecordset("distinct Email")
  9.     If Not rst1.RecordCount = 0 Then
  10.         rst1.MoveFirst
  11.         Do While Not rst1.EOF
  12.             Set OlMail = OlApp.CreateItem(olMailItem)
  13.             OlMail.To = rst1!email
  14.             OlMail.Subject = rst1![Account Number (Short)]
  15.             strSQL = "SELECT * FROM EMAIL WHERE [email] = '" & rst1![email] & "'"
  16.             Set rst2 = Db.OpenRecordset(strSQL, dbOpenDynaset)
  17.             If Not rst2.RecordCount = 0 Then
  18.                 rst2.MoveFirst
  19.                 Do While Not rst2.EOF
  20.                     'Build the body of your message here
  21.                     rst2.MoveNext
  22.                 Loop
  23.             End If
  24.             rst2.close
  25.             Set rst2 = Nothing
  26.             'Send your e-mail here
  27.             rst1.MoveNext
  28.         Loop
  29.     End If
  30.     rst1.Close
  31.     db.Close
  32.     Set rst1 = Nothing
  33.     Set db = Nothing
  34. End Function
Note Lines 20 and 26. This is where you need to accomplish the required tasks.

It is still not clear what is being put into the body of the e-mail. If the content is different for each record, should it be in one e-mail or several?
Dec 1 '14 #13
For example:

Column1 Column2 Column3 Column4 Column5 Column6
123 John Doe $12345 $54321 af@af.com
124 Jane Doe $54321 $12345 af@af.com
125 Jane Jane $55555 $22222 mx@mx.com
126 Joe Joe $12321 $23232 gs@gs.com

So the goal is the macro would send an email to the following:
af@af.com
Body:
message...:
123 John Doe $12345 $54321
124 Jane Doe $54321 $12345

signature
aklsfhasklfh

then another email sent to
mx@mx.com
body:
message...:
125 Jane Jane $55555 $22222
signature
asfdasfa

then next and so on...

The macro would send 3 emails rather than 4... Hope this clears things up. thank you!
Dec 1 '14 #14
Tried this code
Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim ToRecipient As String
  5.     Dim db As DAO.Database
  6.     Dim rst1 As DAO.Recordset
  7.     Dim rst2 As DAO.Recordset
  8.     Dim strSQL As String
  9.  
  10.     'rst1 is the distinct email addresses
  11.     Set db = CurrentDb
  12.     Set rst1 = db.OpenRecordset("distinct Email")
  13.     If Not rst1.RecordCount = 0 Then
  14.         rst1.MoveFirst
  15.         Do While Not rst1.EOF
  16.             Set OlMail = OlApp.CreateItem(olMailItem)
  17.             OlMail.To = rst1!Email
  18.             OlMail.Subject = rst1![Account Number (Short)]
  19.             strSQL = "SELECT * FROM EMAIL WHERE [email] = '" & rst1![email] & "'"
  20.             Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  21.             If Not rst2.RecordCount = 0 Then
  22.                 rst2.MoveFirst
  23.                 Do While Not rst2.EOF
  24.                     'Build the body of your message here
  25.                     rst2.MoveNext
  26.                 Loop
  27.             End If
  28.             rst2.Close
  29.             Set rst2 = Nothing
  30.             'Send your e-mail here
  31.             rst1.MoveNext
  32.         Loop
  33.     End If
  34.     rst1.Close
  35.     db.Close
  36.     Set rst1 = Nothing
  37.     Set db = Nothing
  38. End Function
  39.  
error came out for line 15 as run-time error '91':
object variable or with block variable not set.

Thank you!

-aflores
Dec 1 '14 #15
twinnyfo
3,653 Expert Mod 2GB
Do you have queries (or tables) names "distinct Email" and "EMail"? The only reason those names are there is because I have to make assumptions about the names of your data, as you have not provided it.

Concerning Post #14, above, you must build the code to create the body of the multiple lined e-mails. I can't even begin to build it since I don't know the data that is in your tables--nor do I want to. These are things that we request our posters to work through themselves. We are glad to assist with trouble-shooting, but I want you to understand the concepts I am presenting (even more than I want your project to work). If you understand the concepts, you will be able to expand on those concepts and build more robust projects in the future.
Dec 1 '14 #16
Yes for the first question. I did upload the file from the initial inquiry however, i'll reattach it and rename the queries. The query for distinct is [qry_email distinct] and query for email is [qry_email].

I really hope to get this code to work. I'm researching as well and keep hitting a wall.

Thank you so much for being patient with me.
Attached Files
File Type: zip Sample120114.zip (82.6 KB, 121 views)
Dec 1 '14 #17
twinnyfo
3,653 Expert Mod 2GB
Just modify the code provided so that the recordsets are drawing their data from YOUR queries. This should at least get us moving in the right direction.
Dec 1 '14 #18
I did modify the code
Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim ToRecipient As String
  5.     Dim db As DAO.Database
  6.     Dim rst1 As DAO.Recordset
  7.     Dim rst2 As DAO.Recordset
  8.     Dim strSQL As String
  9.  
  10.  
  11.  
  12.     'rst1 is the distinct email addresses
  13.     Set db = CurrentDb
  14.     Set rst1 = db.OpenRecordset("qry_Email distinct")
  15.     If Not rst1.RecordCount = 0 Then
  16.         rst1.MoveFirst
  17.         Do While Not rst1.EOF
  18.             Set OlMail = OlApp.CreateItem(olMailItem)
  19.             OlMail.To = rst1!Email
  20.             OlMail.Subject = rst1![Account Number (Short)]
  21.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  22.             Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  23.             If Not rst2.RecordCount = 0 Then
  24.                 rst2.MoveFirst
  25.                 Do While Not rst2.EOF
  26.                     'Build the body of your message here
  27.                     rst2.MoveNext
  28.                 Loop
  29.             End If
  30.             rst2.Close
  31.             Set rst2 = Nothing
  32.             'Send your e-mail here
  33.             rst1.MoveNext
  34.         Loop
  35.     End If
  36.     rst1.Close
  37.     db.Close
  38.     Set rst1 = Nothing
  39.     Set db = Nothing
  40. End Function
error came out for line 15 as run-time error '91':
object variable or with block variable not set.
Dec 1 '14 #19
twinnyfo
3,653 Expert Mod 2GB
Do you have the lines:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
At the top of your modules? If not, place them there. Then debug your code (Debug Menu, Compile). Then fix any blatant errors.

Also, you may want to change line 14:

Expand|Select|Wrap|Line Numbers
  1. Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
It "shouldn't" make a difference, but it might.
Dec 1 '14 #20
Error on line 23,
error code: run-time error '91':
object variable or with block variable not set.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4.  
  5. Public Function CreateRIT_ReportEmail()
  6.     Dim OlApp As Object
  7.     Dim OlMail As Object
  8.     Dim olMailItem As Object
  9.     Dim ToRecipient As String
  10.     Dim db As DAO.Database
  11.     Dim rst1 As DAO.Recordset
  12.     Dim rst2 As DAO.Recordset
  13.     Dim strSQL As String
  14.  
  15.  
  16.  
  17.     'rst1 is the distinct email addresses
  18.     Set db = CurrentDb
  19.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  20.     If Not rst1.RecordCount = 0 Then
  21.         rst1.MoveFirst
  22.         Do While Not rst1.EOF
  23.             Set OlMail = OlApp.CreateItem(olMailItem)
  24.             OlMail.To = rst1!Email
  25.             OlMail.Subject = rst1![Account Number (Short)]
  26.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  27.             Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  28.             If Not rst2.RecordCount = 0 Then
  29.                 rst2.MoveFirst
  30.                 Do While Not rst2.EOF
  31.                     'Build the body of your message here
  32.                     rst2.MoveNext
  33.                 Loop
  34.             End If
  35.             rst2.Close
  36.             Set rst2 = Nothing
  37.             'Send your e-mail here
  38.             rst1.MoveNext
  39.         Loop
  40.     End If
  41.     rst1.Close
  42.     db.Close
  43.     Set rst1 = Nothing
  44.     Set db = Nothing
  45. End Function
  46.  
  47.  
I added Dim olMailItem As Object, thinking it might fix the problem but didn't.
Dec 1 '14 #21
I might have found a work around but I might need some ideas with this. I was thinking of creating subdatasheet to group the records by email. Question is how do I send the subdatasheet records that's under the email when expanded?

Thanks. Still the same error from the above code.
Dec 1 '14 #22
Rabbit
12,516 Expert Mod 8TB
Line 23, OlApp, you never set that to anything. It has nothing to work on. You may have declared the variable. But the variable isn't set to anything.
Dec 1 '14 #23
I've set OlApp, however OlMail errors out on line 16. Here's the code below.
error is run-time error 13, type mismatch.
olapp is set in line 10.
Thank you.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim olMailItem As Object
  5.     Dim ToRecipient As String
  6.     Dim db As DAO.Database
  7.     Dim rst1 As DAO.Recordset
  8.     Dim rst2 As DAO.Recordset
  9.     Dim strSQL As String
  10.     Set OlApp = CreateObject("Outlook.Application")
  11.     Set db = CurrentDb
  12.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  13.     If Not rst1.RecordCount = 0 Then
  14.         rst1.MoveFirst
  15.         Do While Not rst1.EOF
  16.             Set OlMail = OlApp.CreateItem(olMailItem)
  17.             OlMail.To = rst1!Email
  18.             OlMail.Subject = rst1![Account Number (Short)]
  19.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  20.             Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  21.             If Not rst2.RecordCount = 0 Then
  22.                 rst2.MoveFirst
  23.                 Do While Not rst2.EOF
  24.                     'Build the body of your message here
  25.                     rst2.MoveNext
  26.                 Loop
  27.             End If
  28.             rst2.Close
  29.             Set rst2 = Nothing
  30.             'Send your e-mail here
  31.             rst1.MoveNext
  32.         Loop
  33.     End If
  34.     rst1.Close
  35.     db.Close
  36.     Set rst1 = Nothing
  37.     Set db = Nothing
  38. End Function
  39.  
  40.  
Also, your name was mentioned before on the previous post and was wondering if you could help me.

The goal is really this:
The macro to send 3 emails rather than 4

For example:

Column1 Column2 Column3 Column4 Column5 Column6
123 John Doe $12345 $54321 af@af.com
124 Jane Doe $54321 $12345 af@af.com
125 Jane Jane $55555 $22222 mx@mx.com
126 Joe Joe $12321 $23232 gs@gs.com

So the goal is the macro would send an email to the following:
af@af.com
Body:
message...:
123 John Doe $12345 $54321
124 Jane Doe $54321 $12345

signature
aklsfhasklfh

then another email sent to
mx@mx.com
body:
message...:
125 Jane Jane $55555 $22222
signature
asfdasfa

then next and so on...

Thank you!


- I'm playing around with subdatasheet and trying to figure out if I could email the subdatasheet of a query but haven't found anything so far.
Dec 1 '14 #24
Rabbit
12,516 Expert Mod 8TB
olMailItem is an object that you declared. The CreateItem method expects an integer, not an object.
Dec 1 '14 #25
twinnyfo
3,653 Expert Mod 2GB
Delete line 4 and line 16 should then work.
Dec 2 '14 #26
Rabbit
12,516 Expert Mod 8TB
You need line 16, you just need to find out what the constant is mapped to and put that in because the outlook constants are out of scope.
Dec 2 '14 #27
zmbd
5,501 Expert Mod 4TB
read this: Bulk-Batch Email From Microsoft Access

The sendkey workaround... yuck.
Once the email object is created it can be sent using the send property. refer to the article.
Dec 2 '14 #28
Thanks zmbd. Hopefully, I could understand the coding and alter it to my use. I wanted to send the concatnated records as a group by to one email address though but I guess I could try and do it manually. I was hoping there was a code out there that would do this automatically. I'll post updates if any.
Dec 3 '14 #29
zmbd
5,501 Expert Mod 4TB
should be able to do that... let me re-read the thread here and see what hits me, been a madhouse on my end and very little time to accomplish anything without interruptions..
Dec 3 '14 #30
Thanks. Looking forward to your response.
Dec 4 '14 #31
Could someone help me with the code below. I'm trying to add records in the body that's associated by email address for example:

Body of email:

text...
record1
record2
record3
record4

all records that corresponds to the email address in to box. See image below.

Line 27 and 28 should loop the records inside the body of the email message. It's not. Could someone help me fix the code?

Many thanks!

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT2_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim olMailItem As Integer
  5.     Dim ToRecipient As String
  6.     Dim db As DAO.Database
  7.     Dim rst1 As DAO.Recordset
  8.     Dim rst2 As DAO.Recordset
  9.     Dim rst3 As DAO.Recordset
  10.     Dim strSQL As String
  11.  
  12.     Set OlApp = CreateObject("Outlook.Application")
  13.     Set db = CurrentDb
  14.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  15.     Set rst3 = db.OpenRecordset("qry_email", dbOpenDynaset)
  16.  
  17.     If Not rst1.RecordCount = 0 Then
  18.         rst1.MoveFirst
  19.         Do While Not rst1.EOF
  20.             Set OlMail = OlApp.CreateItem(olMailItem)
  21.             OlMail.To = rst1!Email
  22.             OlMail.Subject = rst3![ID]
  23.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  24.  
  25.                 Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  26.                 detsubject = "select * from query1 where [email] = '" & rst1![email] & "'"
  27.                 strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  28.                       "  email message body goes here" & detsubject
  29.                 If Not rst2.RecordCount = 0 Then
  30.                     rst2.MoveFirst
  31.  
  32.                 Do While Not rst2.EOF
  33.                 OlMail.Body = strBody
  34.                     'Build the body of your message here
  35.                     rst2.MoveNext
  36.                 Loop
  37.             End If
  38.             rst2.Close
  39.             Set rst2 = Nothing
  40.              OlMail.Display
  41.             'Send your e-mail here
  42.             rst1.MoveNext
  43.         Loop
  44.     End If
  45.     rst1.Close
  46.     db.Close
  47.     Set rst1 = Nothing
  48.     Set db = Nothing
  49. End Function
Attached Images
File Type: jpg Sample-page-0.jpg (36.6 KB, 309 views)
Dec 5 '14 #32
twinnyfo
3,653 Expert Mod 2GB
Line 34:

We have no idea what is contained in rst2, but this is where you build your e-mail content, based on the values in that recordset.
Dec 5 '14 #33
Twinn,

Thank you. That's why I have this on line 32

Expand|Select|Wrap|Line Numbers
  1. OlMail.Body = strBody
the rst2 query has 2 fields: details and email.

Details field is concatenation of all fields from rst3 (line 15). Based on the attached image, it's not looping to add all records that have similar email address from line 26.
Dec 5 '14 #34
twinnyfo
3,653 Expert Mod 2GB
But you have to build that yourself. strBody should be build with all the records of rst2 before you execute that line.

Line 34 could be:

Expand|Select|Wrap|Line Numbers
  1. strBody = strBody & "Your bought this item: " & _
  2.     rst2!Details
  3. rst2.MoveNext
This builds your message based on the multiple items in rst2. I'm not sure there is a need for rst3.
Dec 5 '14 #35
Twinn,

Thank you. I think we're really close. I think we're getting confused with the fields on tables. The code from above doesn't work and the body does not have any population. Please see attached and if you could assist me into completing this.

Many thanks again.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT2_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim olMailItem As Integer
  5.     Dim ToRecipient As String
  6.     Dim db As DAO.Database
  7.     Dim rst1 As DAO.Recordset
  8.     Dim rst2 As DAO.Recordset
  9.     Dim rst3 As DAO.Recordset
  10.     Dim rst4 As DAO.Recordset
  11.     Dim strSQL As String
  12.  
  13.     Set OlApp = CreateObject("Outlook.Application")
  14.     Set db = CurrentDb
  15.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  16.     Set rst3 = db.OpenRecordset("query1", dbOpenDynaset)
  17.  
  18.     If Not rst1.RecordCount = 0 Then
  19.         rst1.MoveFirst
  20.         Do While Not rst1.EOF
  21.             Set OlMail = OlApp.CreateItem(olMailItem)
  22.             OlMail.To = rst1!Email
  23.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  24.  
  25.                 Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  26.                 detsubject = "select * from query1 where [email] = '" & rst1![email] & "'"
  27.                 strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  28.                       "  email message body goes here" & detsubject
  29.                 If Not rst2.RecordCount = 0 Then
  30.                     rst2.MoveFirst
  31.  
  32.                 Do While Not rst3.EOF
  33.                 OlMail.Subject = rst2![ID]
  34.                 OlMail.Body = strBody = strBody & "You bought this item: " & _
  35.                     rst3!Details
  36.                     rst3.MoveNext
  37.                 Loop
  38.             End If
  39.             rst2.Close
  40.             Set rst2 = Nothing
  41.              OlMail.Display
  42.             'Send your e-mail here
  43.             rst1.MoveNext
  44.         Loop
  45.     End If
  46.     rst1.Close
  47.     db.Close
  48.     Set rst1 = Nothing
  49.     Set db = Nothing
  50. End Function
  51.  
Attached Files
File Type: zip Sample120114.zip (159.3 KB, 113 views)
Dec 5 '14 #36
twinnyfo
3,653 Expert Mod 2GB
It seems you are not following much of the advice offered on this thread.

Lines 9, 10, 16 - Delete. These are unnecessary.

Lines 26 and 28: I don't understand your use of detSubject. You are adding "select * from query1 where [email] = 'abc@xyz.com'" to your message.

Line 32: We are still in rst2

Line 33:
Expand|Select|Wrap|Line Numbers
  1. OlMail.Subject = "The Subject of Your E-Mail
Line 34: still rst2
Expand|Select|Wrap|Line Numbers
  1. strBody = strBody & "You bought this item: " & _
  2.     rst2!Details
NB: I don't know if you have a field called "Details" in your table. That was put there, because I still have no clue what is in your tables.

Line 36: rst2 again!

Line 40.5:

Expand|Select|Wrap|Line Numbers
  1. OlMail.Body = strBody
Dec 5 '14 #37
twinn,

thank you. Okay, I have this code now, sorry I can't follow your coding that well.

Thanks.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT2_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim olMailItem As Integer
  5.     Dim ToRecipient As String
  6.     Dim db As DAO.Database
  7.     Dim rst1 As DAO.Recordset
  8.     Dim rst2 As DAO.Recordset
  9.     'Dim rst3 As DAO.Recordset
  10.     'Dim rst4 As DAO.Recordset
  11.     Dim strSQL As String
  12.  
  13.     Set OlApp = CreateObject("Outlook.Application")
  14.     Set db = CurrentDb
  15.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  16.     'Set rst3 = db.OpenRecordset("query1", dbOpenDynaset)
  17.  
  18.     If Not rst1.RecordCount = 0 Then
  19.         rst1.MoveFirst
  20.         Do While Not rst1.EOF
  21.             Set OlMail = OlApp.CreateItem(olMailItem)
  22.             OlMail.To = rst1!Email
  23.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  24.  
  25.                 Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  26.                 detsubject = "select * from query1 where [email] = '" & rst1![email] & "'"
  27.                 strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  28.                       "  email message body goes here" & detsubject
  29.                 If Not rst2.RecordCount = 0 Then
  30.                     rst2.MoveFirst
  31.  
  32.                 Do While Not rst2.EOF
  33.                 OlMail.Subject = rst2![ID]
  34.  
  35.                     rst2.MoveNext
  36.                 Loop
  37.             End If
  38.             rst2.Close
  39.             Set rst2 = Nothing
  40.  
  41.             OlMail.Body = strBody '= strBody & "You bought this item: " & _
  42.                     rst2!Details
  43.             OlMail.Display
  44.             'Send your e-mail here
  45.             rst1.MoveNext
  46.         Loop
  47.     End If
  48.     rst1.Close
  49.     db.Close
  50.     Set rst1 = Nothing
  51.     Set db = Nothing
  52. End Function
  53.  
  54.  
The code is still not looping into adding records. Please see attached db for tables and their fields.

Thank you.
Dec 5 '14 #38
Code is still not working. If anyone out there could help.

This code outputs an email with:

Some kind of greeting! email message body goes hereselect * from query1 where query1.[email] = 'mix@mix.com'

I wanted to have an output where email address is the same as email address from distinct table list all records corresponding that email address.

for example: mix@mix.com
record1
record2
record3
record4
record5

See code below. Please assist.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT2_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim olMailItem As Integer
  5.     Dim ToRecipient As String
  6.     Dim db As DAO.Database
  7.     Dim rst1 As DAO.Recordset
  8.     Dim rst2 As DAO.Recordset
  9.     Dim rst3 As DAO.Recordset
  10.     Dim rst4 As DAO.Recordset
  11.     Dim strSQL As String
  12.  
  13.     Set OlApp = CreateObject("Outlook.Application")
  14.     Set db = CurrentDb
  15.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  16.     Set rst3 = db.OpenRecordset("query1", dbOpenDynaset)
  17.  
  18.     If Not rst1.RecordCount = 0 Then
  19.         rst1.MoveFirst
  20.         Do While Not rst1.EOF
  21.             Set OlMail = OlApp.CreateItem(olMailItem)
  22.             OlMail.To = rst1!Email
  23.  
  24.                 'rst2 = strsql
  25.                 strSQL = "SELECT * FROM qry_EMAIL WHERE qry_EMAIL.[email] = '" & rst1![email] & "'"
  26.                 Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  27.                 'body of email
  28.                 detsubject = "select * from query1 where '" & rst3![email] & "' = '" & rst1![email] & "'"
  29.                 strBody = "Dear " & "," & Chr(10) & Chr(10) & "Some kind of greeting" & "!" & _
  30.                       "  email message body goes here" & detsubject
  31.                 If Not rst2.RecordCount = 0 Then
  32.                     rst2.MoveFirst
  33.  
  34.                 Do While Not rst2.EOF
  35.                 OlMail.Subject = rst2![ID]
  36.  
  37.                     rst2.MoveNext
  38.                 Loop
  39.             End If
  40.             rst2.Close
  41.             Set rst2 = Nothing
  42.  
  43.             OlMail.Body = strBody '= strBody & "You bought this item: " & _
  44.                     rst2!Details
  45.             OlMail.Display
  46.             'Send your e-mail here
  47.             rst1.MoveNext
  48.         Loop
  49.     End If
  50.     rst1.Close
  51.     db.Close
  52.     Set rst1 = Nothing
  53.     Set db = Nothing
  54. End Function
  55.  
  56.  
Dec 8 '14 #39
twinnyfo
3,653 Expert Mod 2GB
aflores,

What amount of VBA coding experience do you have? It appears, to the casual observer, that you are adding various statements to your code without any comprehension of what they mean. If this is the case, there is little hope that any of us experts will be able to assist you much beyond your current state of success with this project.

Against my better judgment, I will modify your code to hopefully assist you in finalizing this thread.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT2_ReportEmail()
  2.     Dim OlApp As Object
  3.     Dim OlMail As Object
  4.     Dim olMailItem As Integer
  5.     Dim db As DAO.Database
  6.     Dim rst1 As DAO.Recordset
  7.     Dim rst2 As DAO.Recordset
  8.     Dim strBody As String
  9.     Dim strSQL As String
  10.  
  11.     Set OlApp = CreateObject("Outlook.Application")
  12.     Set db = CurrentDb
  13.     Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  14.  
  15.     If Not rst1.RecordCount = 0 Then
  16.         rst1.MoveFirst
  17.         Do While Not rst1.EOF
  18.             Set OlMail = OlApp.CreateItem(olMailItem)
  19.             OlMail.To = rst1!EMail
  20.             OlMail.Subject = "This is the Subject of Your E-Mail!"
  21.             strBody = "Dear " & "," & Chr(10) & Chr(10) & _
  22.                 "Hello Person!  I am greeting you!" & vbCrLf & vbCrLf & _
  23.                 "This is the e-mail Body -- finish it please!" & vbCrLf & vbCrLf
  24.             strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  25.  
  26.             Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  27.             If Not rst2.RecordCount = 0 Then
  28.                 rst2.MoveFirst
  29.                 Do While Not rst2.EOF
  30.                     strBody = strBody & rst2![One of your Fields]
  31.                     strBody = strBody & rst2![Another Field]
  32.                     rst2.MoveNext
  33.                 Loop
  34.             End If
  35.             rst2.Close
  36.             Set rst2 = Nothing
  37.  
  38.             OlMail.Body = strBody
  39.             OlMail.Display
  40.             'Send your e-mail here
  41.             rst1.MoveNext
  42.         Loop
  43.     End If
  44.     rst1.Close
  45.     db.Close
  46.     Set rst1 = Nothing
  47.     Set db = Nothing
  48. End Function
I have little confidence that this will work without you making necessary changes which reflect the actual data in the actual tables that your actual recordsets will be generating. Please review the code above and modify it so that it will take into account your specific data.
Dec 8 '14 #40
Twinn,

I got your code to work. Thank you so much! Just needed to modify the query.

This inquiry is now closed! See complete code below.

Expand|Select|Wrap|Line Numbers
  1. Public Function CreateRIT23_ReportEmail()
  2. Dim OlApp As Object
  3. Dim OlMail As Object
  4. Dim olMailItem As Integer
  5. Dim db As DAO.Database
  6. Dim rst1 As DAO.Recordset
  7. Dim rst2 As DAO.Recordset
  8. Dim strBody As String
  9. Dim strSQL As String
  10.  
  11. Set OlApp = CreateObject("Outlook.Application")
  12. Set db = CurrentDb
  13. Set rst1 = db.OpenRecordset("qry_Email distinct", dbOpenDynaset)
  14.  
  15. If Not rst1.RecordCount = 0 Then
  16. rst1.MoveFirst
  17. Do While Not rst1.EOF
  18. Set OlMail = OlApp.CreateItem(olMailItem)
  19. OlMail.To = rst1!Email
  20. OlMail.Subject = "This is the Subject of Your E-Mail!"
  21. strBody = "Dear " & "," & Chr(10) & Chr(10) & _
  22. "Hello Person!  I am greeting you!" & vbCrLf & vbCrLf & _
  23. "This is the e-mail Body -- finish it please!" & vbCrLf & vbCrLf
  24. strSQL = "SELECT * FROM qry_EMAIL WHERE [email] = '" & rst1![email] & "'"
  25.  
  26. Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  27. If Not rst2.RecordCount = 0 Then
  28. rst2.MoveFirst
  29. Do While Not rst2.EOF
  30. strBody = strBody & rst2![expr1] & vbCrLf & vbCrLf
  31. 'strBody = strBody & rst2![Emaila]
  32. rst2.MoveNext
  33. Loop
  34. End If
  35. rst2.Close
  36. Set rst2 = Nothing
  37.  
  38. OlMail.Body = strBody
  39. OlMail.Display
  40. 'Send your e-mail here
  41. rst1.MoveNext
  42. Loop
  43. End If
  44. rst1.Close
  45. db.Close
  46. Set rst1 = Nothing
  47. Set db = Nothing
  48. End Function
  49.  
  50.  
  51.  
Dec 8 '14 #41
Twinn,

Could you help me modify the query above into instead of sending the transactions as part of the body of the email into sending it as excel attachment?

Same rules apply as to grouping the email by a field i.e. Name.

Let me know if you have any questions.

Thanks Twinn!
Jan 15 '15 #42
twinnyfo
3,653 Expert Mod 2GB
Just export the query to Excel, keeping track of the path and file name, then include it as an attachment:

Expand|Select|Wrap|Line Numbers
  1. OlMail.Body = strBody
  2. OlMail.Attachment.Add "FilePath\FileName.xlsx"
  3. OlMail.Display
  4.  
Hope this hepps!
Jan 21 '15 #43
Thanks Twinn. However, the query sends out mass email by grouping data into based on grouped field so there'll be many saved files in the folder if we do it this way. I guess the question is how do I automatically attach the saved file to the correct email if we do it this way.
Thanks.
Jan 26 '15 #44
twinnyfo
3,653 Expert Mod 2GB
There is no way to "attach" a query or report in Excel format. You must save it first. You could simply delete the files you create once you send them ("Kill" Statement), so delete everything in the folder when you are complete.
Jan 26 '15 #45

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

Similar topics

2
by: Lin Ma | last post by:
Greetings, In my search application, user can type a number to search. I use LIKE in my query. If a query result generates over 10,000 recordsets, it may several minutes to run. Is there a...
11
by: Surajit Laha | last post by:
I am firing a query like: SELECT TaskName, StartDate FROMTasks WHERE StartDate >= '01-Aug-2003' Now the result comes as: TaskName StartDate -------------------------- Task1 ...
7
by: Marcin | last post by:
Hello all! A few years ago I created a form with button which let me send an email with an attachment. It was created in Access 97. Now I would like to move this application into Access 2003....
17
by: Bonj | last post by:
Right guys. (I would like a solution to this in VB6 as this is what our needy app is written in, but any solutions that involve .NET would be much appreciated likewise as I could instantiate...
6
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
1
by: Matt | last post by:
I need to email query results from Access similar to the way I do in SQL using xp_sendmail. What is the best way to accomplish this? Thanks!
0
by: The Programmer | last post by:
Assistance needed urgently! I use a Sybase Database with SQL Anywhere 9 and need to send the SQL query result as the body of the e-mail from within SQL. Here's what I have thusfar: ...
0
by: The Programmer | last post by:
Assistance needed urgently! I use a Sybase Database with SQL Anywhere 9 and need to send the SQL query result as the body of the e-mail from within SQL. Here's what I have thusfar: ...
1
ddtpmyra
by: ddtpmyra | last post by:
how can I capture the query result in PHP? I have two queries below: # Fetch the file information $query ="update filestorage set approved ='Y' where FileID = {$id}"; $query1 ="select...
2
by: mrdatabase1 | last post by:
I have this query and it works fine however i need the query to display the forename and surname and currently it only displays the max value of the sum it performs Does anybody know what i can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.