473,675 Members | 3,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Outlook vba connected to Access Error-help

27 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Sub test()
  4. Dim rsAccountNumber As DAO.Recordset
  5. Dim olApp As Outlook.Application, olEmail As Outlook.MailItem
  6. Dim fileName As String, todayDate As String, strEmail As String
  7.  
  8. todayDate = Format(Date, "YYYY-MM-DD")
  9.  
  10. Set rsAccountNumber = CurrentDb.OpenRecordset("SELECT DISTINCT EmployeeID, [email] FROM [queAutoUpdate]", dbOpenSnapshot)
  11. Set olApp = New Outlook.Application
  12.  
  13. With rsAccountNumber
  14.      Do Until .EOF
  15.          ' SETTING FILE NAME TO SAME PATH AS DATABASE (ADJUST AS NEEDED)
  16.          fileName = Application.CurrentProject.Path & "\Desktop\trial.accdb" & !EmployeeID & "_" & todayDate & ".pdf"
  17.  
  18.          ' OPEN AND EXPORT PDF TO FILE
  19.          DoCmd.OpenReport "test", acViewPreview, "EmployeeID = '" & !EmployeeID & "'"
  20.          ' INTENTIONALLY LEAVE REPORT NAME BLANK FOR ABOVE FILTERED REPORT
  21.          DoCmd.OutputTo acReport, , acFormatPDF, fileName, False
  22.          DoCmd.Close acReport, "test"
  23.  
  24.          ' CREATE EMAIL OBJECT
  25.          strEmail = ![email]
  26.          Set olEmail = olApp.CreateItem(olMailItem)
  27.          With olEmail
  28.              .Recipients.Add strEmail
  29.              .Subject = "Updated Balance"
  30.              .Body = "Text Here"
  31.              .Attachments.Add fileName        ' ATTACH PDF REPORT
  32.              .Send                               ' SEND WITHOUT DISPLAY TO SCREEN
  33.          End With
  34.  
  35.          Set olEmail = Nothing
  36.          .MoveNext
  37.      Loop
  38.      .Close
  39. End With
  40. End Sub
  41.  
however, I keep receiving "Compile error: Variable not defined" at different locations. This time I have it at
Expand|Select|Wrap|Line Numbers
  1. Set rsAccountNumber = CurrentDb.OpenRecordset
Feb 20 '19 #1
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.
Feb 21 '19 #2
beginneraccess
27 New Member
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?
Feb 21 '19 #3
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!
Feb 21 '19 #4
beginneraccess
27 New Member
Thanks twinnyfo!
I have looked into two issues of downloading ClickYes app or just doing a mailmerge :)
Feb 22 '19 #5

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

Similar topics

11
12080
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
0
1526
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).
0
1142
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...
1
5336
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
0
1720
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
1
2459
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.
2
4031
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.
2
1359
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.
4
9884
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?
5
9112
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...
0
8451
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,...
0
8968
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, 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...
0
7501
agi2029
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...
0
5756
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();...
0
4261
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...
0
4467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2867
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
2
2125
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1867
bsmnconsultancy
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...

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.