I have an Access database where I want to send a PDF file as an attachment. I have code that sends the basic email from Access through LotusNotes and it works well. What I would like help on is:
Does LotusNotes need to be configured any certain way to handle the attachment?
I also need help with the VBA code to attach the PDF file to the email. The PDF name is Report1 and will be stored here C:\Temp\Report1 .pdf Each time a new file is created, it will have the same name and will be overwritten each time. If code is need to allow time for the PDF to be written, help with the code would be nice.
I am using a table to store the To:, CC:, Email address:, etc. The queries in code delete the table or append new data as needed. Please reply if you need further clarification on this part of my code.
I have tried several pieces of code found on websites, but I'm not doing something right......I need someone's help with this.
I'm new to writing code in VBA, so any help will be greatly appreciated.
My code is below and works well for what I want to do, except for attachments. If anyone can help. please modify my code.
Private Sub MGR_Send_Email_ Click()
Dim defPrinter As String, NewPrinter As Printer
'Get the default printer name
defPrinter = Application.Pri nter.DeviceName
'Create a new printer object
Set NewPrinter = Application.Pri nters("CutePDF Writer") 'use your printer name here
'Set the default printer to the new printer
Set Application.Pri nter = NewPrinter
'Open the report
DoCmd.OpenRepor t "Report1", acViewNormal 'use your actual report name here
'Print the report (the next line seems to print the report and the form so I removed it, if your report doesn't print then remove the apostrophe on the next line)
'DoCmd.PrintOut
'Close the report
DoCmd.Close acReport, "Report1", acSaveNo 'report name again!
'Reset the printer back to the default printer
Set NewPrinter = Application.Pri nters(defPrinte r)
Set Application.Pri nter = NewPrinter
Dim stDocName As String
Dim stDocName1 As String
Dim stDocName2 As String
Dim stDocName3 As String
Dim stDocName4 As String
stDocName = " MRG_Temp_Email App qry"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocName1 = " MGR_Temp_Auto_E mail App qry"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
If MsgBox("Ready to Automatically Send Email?", vbOKCancel, "Confirm") = vbOK Then
Dim db As DAO.Database
Dim rstAutoEmail As DAO.Recordset
Dim strTo As String
Dim strCC As String
Dim strBCC As String
Dim strSubject As String
Dim strBody As String
Set db = CurrentDb()
Set rstAutoEmail = db.OpenRecordse t("MGR_Temp_Aut oEmail", dbOpenDynaset)
Do Until rstAutoEmail.EO F
strTo = rstAutoEmail![To email]
strCC = ""
If Not IsNull(rstAutoE mail![CC email]) Then strCC = rstAutoEmail![CC email]
strBCC = ""
If Not IsNull(rstAutoE mail![BCC email]) Then strBCC = rstAutoEmail![BCC email]
strBody = rstAutoEmail!Bo dy
strSubject = rstAutoEmail![Subject]
If MsgBox("Send This Email to " & strTo & "?", vbOKCancel, "Confirm") = vbOK Then
SendMail strTo, strCC, strBCC, strSubject, strBody, ""
End If
rstAutoEmail.Mo veNext
Loop
rstAutoEmail.Cl ose
db.Close
End If
On Error GoTo Err_MGR_Send_Em ail_Click
stDocName2 = "MGR Review qry"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
stDocName3 = "MGR_Temp_E mail Del qry"
DoCmd.OpenQuery stDocName3, acNormal, acEdit
stDocName4 = "MGR_Temp_Auto_ Email Del qry"
DoCmd.OpenQuery stDocName4, acNormal, acEdit
Exit_MGR_Send_E mail_Click:
Exit Sub
Err_MGR_Send_Em ail_Click:
MsgBox Err.Description
Resume Exit_MGR_Send_E mail_Click
End Sub
2 4391 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Paul Lamonby |
last post by:
Hi,
I am sending a file from the server as an email attachment. The file
is being attached no problem and sending the email, but I get an error
when I try to open it saying it is corrupt. Obviuosly, the file is
fine on the server, so the attachment code I am using must be
corrupting it, but I dont know what it is:
// send email with attachment
function emailAttachment($to, $subject, $message, $name, $email,
|
by: Brian Loesgen |
last post by:
The next San Diego .Net User Group meeting is Tuesday, November 25,
2003 at the Scripps Ranch Library.
Scripps Ranch Library
10301 Scripps Lake Drive
San Diego, CA 92131-1026
Please join us at 6:00 pm for pizza and networking. The meeting starts
at 6:30 pm.
|
by: Susan Bricker |
last post by:
I would like to generate a report (I have the report working already)
using MS/ACCESS 2000 and then have the ability to send the report as an
email attachment to my colleagues. I have looked around in the
MS/ACCESS Help facility and found that I can click on FILE (on the Menu
Bar) and then click on SEND TO. This will generate, either, a 'Snapshot
format' or 'Rich Text Format' file and send an email.
Two problems:
1. Is it possible to...
|
by: Ramzey |
last post by:
I've looked through the MSDN documentation on code access security and
can not seem to find an answer to my question.
I have a class XYZCorpWebPage that uses System.Web.UI.Page as it's
base class. I want to make it so that the web server will throw an
exception/deny runtime rights to any WebForm derived from
System.Web.UI.Page, but I want to allow runtime rights on
XYZCorpWebPage (I want to force our developers to use XYZCorpWebPage
as...
|
by: c_shah |
last post by:
how to save outlook email attachments using VB.net?
| |
by: edwngy |
last post by:
I can not open a Web application Download into Excel: As soon as I try to download C_applic.xls (application/vnd.ms-excel) to Excel, Excel was opened, but then I got an error message which said, 'C_applic~1.xls: File Format is not valid.' I then clicked on 'HELP' and I got the following: '' file format is not valid. Please help on this. You can look under 'Windows' and you will see the entire process I used to down load the e-mail...
|
by: bloukopkoggelmander |
last post by:
Hi all
I have a bit of a strange problem where I want to set a table field in Access 2007 to an attachment field, but when I follow the Microsoft workmethod, I get no option in Access for attachment. It should be there, but hey, it's not!
Here is the workmethod I am following : http://office.microsoft.com/en-us/access/HA012138521033.aspx?pid=CH100728901033
Does anyone have this same problem, or does anyone know why I might not have...
|
by: ProgrammerChicago |
last post by:
Is there any way to upload and download files using the Access 2007
attachment field type in an ASP.NET webpage?
I found this article pertaining to SQL Server 2005 (http://aspnet.
4guysfromrolla.com/articles/120606-1.aspx), but it's a little complex
for me, and it might be better to have some documenting the procedure
with Access -- that is, if it is at all possible.
|
by: newsco |
last post by:
Dear all,
I use VB6 ADO connect to Access 2007 accdb database, everything is fine except I cannot retrieve image file stored in the Access 2007 attachment data type.
Can anyone show me some vb code on how to do that?
Thanks.
Patrick
|
by: rismy |
last post by:
The code for PDF attachment (system generated)via Email
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |