473,386 Members | 1,702 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,386 software developers and data experts.

Add CC and Signature to Email

I found code here (thank you) to get my email to load query results to specific emails.

I just need to add a CC email and the signature at the bottom of the email.
I have tried several things and it all results in either I get the query data without signature or I get the signature.
So I'm asking for help. I am not a programmer.

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Function EmailCostNeeded()
  5. Dim OlApp As Object
  6. Dim OlMail As Object
  7. Dim signature As String
  8. Dim olMailItem As Integer
  9. Dim db As DAO.Database
  10. Dim rst1 As DAO.Recordset
  11. Dim rst2 As DAO.Recordset
  12. Dim strBody As String
  13. Dim strSQL As String
  14. Set OlApp = CreateObject("Outlook.Application")
  15. Set db = CurrentDb
  16.  
  17. 'rst1 is the distinct email addresses
  18. Set rst1 = db.OpenRecordset("q_email_distinct", dbOpenDynaset)
  19. If Not rst1.RecordCount = 0 Then
  20.     rst1.MoveFirst
  21.     Do While Not rst1.EOF
  22.         Set OlMail = OlApp.CreateItem(olMailItem)
  23.         OlMail.To = rst1!contact
  24.         OlMail.Subject = "Cost Sheets Needed"
  25.         strBody = "Cost Sheets are needed for the following Product IDs. " & vbCrLf & _
  26.         "Thank You" & signature & vbCrLf & vbCrLf & _
  27.         "Account Corp   DIV       PRODID              Vendor" & vbCrLf
  28.  
  29. strSQL = "SELECT * FROM q_us_stdcost_needed WHERE [contact] = '" & rst1![contact] & "'"
  30.  
  31. Set rst2 = db.OpenRecordset(strSQL, dbOpenDynaset)
  32.  
  33. If Not rst2.RecordCount = 0 Then
  34.     rst2.MoveFirst
  35.     Do While Not rst2.EOF
  36.     strBody = strBody & rst2![Account] & vbTab
  37.     strBody = strBody & rst2![company] & vbTab
  38.     strBody = strBody & rst2![Div] & vbTab
  39.     strBody = strBody & rst2![Prod_Id] & vbTab
  40.     strBody = strBody & rst2![Vendor_Short] & vbCrLf
  41.     rst2.MoveNext
  42.  
  43. Loop
  44.  
  45. End If
  46.  
  47. rst2.Close
  48. Set rst2 = Nothing
  49.  
  50. OlMail.body = strBody
  51. OlMail.display
  52. 'Send your e-mail here - change OlMail.display to OlMail.send
  53. rst1.MoveNext
  54. Loop
  55. End If
  56.  
  57.  
  58. rst1.Close
  59. db.Close
  60. Set rst1 = Nothing
  61. Set db = Nothing
  62. End Function
  63.  
Mar 27 '18 #1
0 1821

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

Similar topics

12
by: Kim | last post by:
I have a .NET service sending mails using CDOEX. These mails I need to sign. I got a tip that I should use CAPICOM. That worked fine sending a mail with signature. BUT the problem is that I...
5
by: jdph40 | last post by:
I have a form in Access 97 on which I have an unbound list box filled with our employees names from tblEmployees. When you select an employee's name and click a button, the following code is run...
1
by: Marco Moioli | last post by:
Hi, I have a problem with a X509 digital signature. I want to sign a Word 2003 document saved in .xml format. the problem is that after the signature, Word 2003 don't want to open the document. ...
3
by: Nicky | last post by:
hi, all Our program on handheld supports signature. And I am moving the code to laptop. But it seems impossible to support signature without other hardware device like "Writing Pad". Does anyone...
0
by: VP | last post by:
g'day, i am posting a problem i have encountered with creating an email using outlook through some basic c# code. the problem arises when using different email editors in outlook. At the moment...
1
by: JJBW | last post by:
Hi I am creating some aspx files in Visual Studio 2003 for a Danish web site. The page is encoded as UTF-8 - However, when I save the the aspx file as "UTF-8 without signature" the Danish...
0
by: Michael R. Pierotti | last post by:
Has anyone seen this error before when trying to make the install on a program. ------ Starting pre-build validation for project 'HafaSMPPInstall' ------ WARNING: Unable to find dependency...
10
by: AG | last post by:
I need to create a ASP.NET (3.5) web app where the client machine will be a tablet pc. The app will have a patient consent form that the patient would sign using the stylus. I would need to save...
0
by: tasawer | last post by:
Hi, I wish to send email with signature from within MSAccess. I have found the code below (http://www.rondebruin.nl/) that helps me to do exactly that however, any images within the signature do...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.