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

Export Acces form records to email message..

P: 1
Hi everyone i have a question and really hope someone can help me out:

In acces i have made a form with several records, the information in those records are send out to the body of a email message in Outlook i did that by a VBA code so if a users presses on that button it will do the job, but the problem is that it only picks the data of the current record and not all records of the form.


Is there a way to do this?

The code that i currently using is below:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Send_Mail_Click() 
  2.  
  3.     Set fso = CreateObject("Scripting.FileSystemObject") 
  4.     Set olObj = GetObject(, "Outlook.Application") 
  5.     Set olmail = olObj.createitem(olMailItem) 
  6.  
  7.  
  8.  
  9.  
  10.     olmail.Subject = "Training" 
  11.     olmail.Importance = "2" 
  12.     olmail.To = "" 
  13.     olmail.cc = "" 
  14.     olmail.bcc = "" 
  15.     olmail.htmlbody = "<p> Hello, here are the dates</p> " & vbNewLine & vbNewLine & "Title:" & " " & [Title] & vbNewLine & "Location:" & " " & [Location] & vbNewLine & "Start Time:" & " " & [Start Time] & vbNewLine & "End Time:" & " " & [End Time] & vbNewLine & vbNewLine & "Description:" & " " & [Description] & vbNewLine 
  16.     Email_Subject = "Training dates" 
  17.     olmail.display 
  18.  
  19.  
  20.  
  21.     On Error Goto debugs 
  22.     Set Mail_Object = CreateObject("Outlook.Application") 
  23.     Set Mail_Single = Mail_Object.createitem(0) 
  24.     With Mail_Single 
  25.         .Subject = Email_Subject 
  26.         .To = Email_Send_To 
  27.         .cc = Email_Cc 
  28.         .bcc = Email_Bcc 
  29.         .Body = Email_Body 
  30.  
  31.         .send 
  32.     End With 
  33. debugs: 
  34.     If Err.Description <> "" Then MsgBox Err.Description 
  35.  
  36.  
  37.  
  38. End If 
  39.  
  40.  
Apr 3 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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