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

I would like to adapt this code so i can send by email not print if possible

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdmail_Click()
  2. On Error GoTo Err_cmdmail_Click
  3.  
  4.     Dim strDocName As String
  5.  
  6.  
  7.     strDocName = "rptSeabooking"
  8. ' Print booking report, using seabooking Filter query to print
  9.     ' booking report for current booking.
  10.     DoCmd.OpenReport strDocName, acViewNormal, "qrybookingfilter"
  11.  
  12. Exit_cmdmail_Click:
  13.     Exit Sub
  14.  
  15. Err_cmdmail_Click:
  16.     ' If action was cancelled by the user, don't display an error message.
  17.     Const conErrDoCmdCancelled = 2501
  18.     If (Err = conErrDoCmdCancelled) Then
  19.         Resume Exit_cmdmail_Click
  20.     Else
  21.         MsgBox Err.Description
  22.         Resume Exit_cmdmail_Click
  23.     End If
  24. End Sub
Feb 18 '11 #1
2 1395
jimatqsi
1,271 Expert 1GB
Erik,
You don't say what platform you're working in. This solution doesn't work in Access 2010.

The first thing you need to do is to print your report to a pdf and then you can email the pdf. Steven Lebans created the code a lot of folks use to create pdfs from within VB/VBA code. It's really not bad to set up but it'll take a little time. You can get all you need to know here http://www.lebans.com/reporttopdf.htm. There's also some information here http://www.granite.ab.ca/access/pdffiles.htm

The first one of these you do will require a fair bit of work, but then it's a snap to call on the infrastructure you built for the first one.

As for sending the email, there are several ways to do that, depending on whether you want to go through Outlook or not (stupid little security window pops up), your system security settings and probably other things particular to your operating environment. I prefer using the CDO email method. You can read about that here http://bytes.com/topic/access/answer...ail-cdo-access or http://bytes.com/topic/access/answer...before-sending.

You can find lots of help on both of these topics by searching the web.

Jim
Feb 18 '11 #2
Hi Jim,

Thanks for the reply.

I am currently using Access 2007. The code above allows me to filter a certain customer and then print to default printer, I tried to use sendobject to print and then send via email using outlook, works but it wont filter does a pdf for all records in table. Thank you for the links I am currently reading and hope to learn new things.
Feb 23 '11 #3

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

Similar topics

3
by: Salim Afþar | last post by:
Hi, I'm using CDO object to send email but it doesn't send any email and it does not give an error. My code look like this: Dim iMsg2 Dim iConf2 Dim Flds2 Const cdoSendUsingPort = 2 set...
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
2
by: ucasesoftware | last post by:
i start a process to send email via Outlook I have succes to build the email text, objet, sender... but i want to automate the "send"... i don't want my users to click on Send email button......
4
by: CLEAR-RCIC | last post by:
I want to send an email from our Intranet site to myself whenever an error happens. Our manager will not let us install SMTP on the web server. Is it possible to send email programatically...
0
by: Kun | last post by:
the code below outputs a string of emails (e.g. i would like to somehow send an email to everyone on the string of emails telling them 'thanks for emailing me' anyone know how to do this?...
3
by: sentiboy | last post by:
I am using the following code for sending email through mapi in VS 2005 environment: Public objSession As New MSMAPI.MAPISession Public objMessage As New MSMAPI.MAPIMessages ...
16
by: =?Utf-8?B?Q2hlZg==?= | last post by:
I can use outlook2003 to send email,but I cann't use this code below to send email. Please help me to test this code and instruct me how to solve this problem in detail. software...
14
by: Warren Tang | last post by:
Hi I am using the mail function to send a mail like this: $b = mail("my_real_email_address@gmail.com", "Hello from PHP", "Hi, finally sent an email successfully"); But it failed. Could you...
8
reginaldmerritt
by: reginaldmerritt | last post by:
Hi, I have two report layouts that are used to run 12 different reports using where statement. for example DoCmd.OpenReport "SomeReport", _ acViewPreview, _ ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.