In my last question (https://bytes.com/topic/access/answers/972172-split-ms-access-reports-into-separate-emails) I wanted to make separated reports from one big report and have them sent matching the EmployeeIDs and Emails... However after every email I get a message from Microsoft Outlook:
"A program is trying to send an e-mail message on your behalf. If this is unexpected, click Deny and verify your antivirus is up-to-date...."
so someone suggested to try coding VBA through Outlook and suggested: - Option Explicit
-
-
Sub test()
-
Dim rsAccountNumber As DAO.Recordset
-
Dim olApp As Outlook.Application, olEmail As Outlook.MailItem
-
Dim fileName As String, todayDate As String, strEmail As String
-
-
todayDate = Format(Date, "YYYY-MM-DD")
-
-
Set rsAccountNumber = CurrentDb.OpenRecordset("SELECT DISTINCT EmployeeID, [email] FROM [queAutoUpdate]", dbOpenSnapshot)
-
Set olApp = New Outlook.Application
-
-
With rsAccountNumber
-
Do Until .EOF
-
' SETTING FILE NAME TO SAME PATH AS DATABASE (ADJUST AS NEEDED)
-
fileName = Application.CurrentProject.Path & "\Desktop\trial.accdb" & !EmployeeID & "_" & todayDate & ".pdf"
-
-
' OPEN AND EXPORT PDF TO FILE
-
DoCmd.OpenReport "test", acViewPreview, "EmployeeID = '" & !EmployeeID & "'"
-
' INTENTIONALLY LEAVE REPORT NAME BLANK FOR ABOVE FILTERED REPORT
-
DoCmd.OutputTo acReport, , acFormatPDF, fileName, False
-
DoCmd.Close acReport, "test"
-
-
' CREATE EMAIL OBJECT
-
strEmail = ![email]
-
Set olEmail = olApp.CreateItem(olMailItem)
-
With olEmail
-
.Recipients.Add strEmail
-
.Subject = "Updated Balance"
-
.Body = "Text Here"
-
.Attachments.Add fileName ' ATTACH PDF REPORT
-
.Send ' SEND WITHOUT DISPLAY TO SCREEN
-
End With
-
-
Set olEmail = Nothing
-
.MoveNext
-
Loop
-
.Close
-
End With
-
End Sub
-
however, I keep receiving "Compile error: Variable not defined" at different locations. This time I have it at - Set rsAccountNumber = CurrentDb.OpenRecordset
4 1292 twinnyfo 3,653
Recognized Expert Moderator Specialist
The warning you are receiving (at the beginning of your post) is not an error but is based upon the network settings of your IT department. The only way you can send e-mails without this warning is to have your IT department change the security settings of your network. I can almost guarantee that this will NOT happen. The only way to avoid the warning is to have the e-mail pop up for editing and then click send on each individual e-mail. This may be a pain, but the simplicity of simply clicking send (as many times as necessary) is a much better solution than an unsecure network.
Thanks twinnyfo!
I was hoping the code in Outlook would be a work around... Do you think the "Compile error: Variable not defined" in Outlook is due to IT as well?
twinnyfo 3,653
Recognized Expert Moderator Specialist
The second part is not an IT issue, but I did not research your code in depth. It "appears" to be correct.
However, you may want to check out this article on Sending e-mails via Outlook, which can simplify this process for you over the long haul. This eliminates many of the repetitive redundancies that may occur when you have a DB that sends a lot of e-mails (ours sends about a thousand every month).
Hope this hepps!
Thanks twinnyfo!
I have looked into two issues of downloading ClickYes app or just doing a mailmerge :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Google Mike |
last post by:
I've got RH9 Linux with default PHP.
Is there a way to send email on Linux to an Exchange Server from PHP
and/or other tools when there is *NOT* SMTP access?
Has anyone figured out a way to use PHP to get inside an OWA (Microsoft
Outlook Web Access) website to send email that way?
The reason I ask is because my corporate office is going to do away
with our rogue SMTP server access and force everything through Exchange
|
by: Raed Sawalha |
last post by:
I wondering what should I do to embed Outlook Web Access within aspx page
(say inside frame or iframe).
|
by: forbisthemighty |
last post by:
A familiar behavior seen in Outlook Web Access is mini-browser windows
that pop up telling the user a task is due for completion or an
appointment is coming up. I'm looking for ideas on how this is done. I
would assume the process is something like this...
1) A SQL call is generated every five minutes or so, saying "Select all
tasks owned by this user where due date is less 24 hours away."
2) Outlook Web Access then takes the results of...
|
by: Vince Varallo |
last post by:
Hello everyone,
Is there any way to create a single sign on solution that can authenticate a
user and then store the credentials and pass them to outlook web accees?
Essentially we want the first web page to ask the user for the user name and
password and the second page to give the user options of what applications
they can access, one of them being Outlook Web Access.
Thanks for your help,
Vince
|
by: eric.nguyen312 |
last post by:
Hi, is there a way to double click an email address in a contacts form
that opens up Outlook Web Access and fills in the email address?
Thanks,
Eric
| |
by: =?Utf-8?B?VGVkZXNjbw==?= |
last post by:
I am running Outlook Express 6 on my home computer. I am able to
access my work email from home it is Outlook Web Access. I understand that
the two are different. I can not insert pictures with Outlook Web Access,
I can not do half of what I can with Outlook Express 6. How can I make
Outlook Web Access more like my home Outlook Express 6? (Inserting pictures)
Thanks.
|
by: =?Utf-8?B?TWFydGluIEFkaGll?= |
last post by:
Hi All,
Anyone knows where can I get Outlook Web Access (OWA) 2003 look and feel
template code in asp.net 2.0?
This download for windows based Outlook 2003 look and feel template.
http://windowsclient.com/downloads/folders/applications/entry1338.aspx
I'm very like it. It can be used for any other application based on that
windows UI. So now I'm looking for web based.
|
by: =?Utf-8?B?dGlnZXJhbW9uZ3BpZ3M=?= |
last post by:
my wife uses outlook web access, but recently it has stopped remembering the
password. even when the box "remember the password" is checked, it has to be
typed back in the next time it is used. i would appreciate any info you can
give. thanks.
|
by: macca |
last post by:
hi,
Does anybody know if it's possible to log into Outlook Web Access
using PHP?
I mean, if I have the username, password and email address I need to
have a link that opens directly into Outlook Web Access inbox or
something. Is this possible, and if so, does anyone know where I can
find more information on how to do this?
|
by: BikeToWork |
last post by:
A user is sending out a mass mailing through Outlook via Access automation. Many of these email addresses are obsolete and the email will bounce back to Outlook as "undeliverable." The user wants to update his list of email addresses in the application so that he avoids the invalid email addresses for future mailings. Is there any way to get a list of the bounced email addresses from Outlook into Access? The user can put all the bounced emails...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |