26. (Advanced Programming In Access 2013) Send Outlook Email With VBA
Вставка
- Опубліковано 19 вер 2024
- Send Outlook Email With VBA video in the "Advanced Programming in Microsoft Access 2013" series hosted by Steve Bishop. In this free advanced video tutorial series Steve will be going over Microsoft SQL Server installation, Database Migration, creating a better User Interface, using external data sources, complex Visual Basic For Applications (VBA) concepts and distributing your application.
Click here for the full playlist of "Advanced Programming in Access 2013":
• 1. (Advanced Programmi...
Click here for the Work Files of this series:
github.com/Xip...
I always thank to Steve.. for more than 5 years.. simple, easy, and get to direct point, and very kind instruction...
Surely this is the very best instruction on email sending from Access!!!!!!!
I have looked everywhere for an email solution. This is great - you explain everything so well and best of it - it works!! Thanks heaps
Dude you're a GENIUS! Thanks for this video.
Hi Steve
Excellent Tutorials, Thanks a lot Steve for uploading this videos, it’s really helpful, never found such good videos.
Great vid Steve. Thanks for all your great stuff. I have watched all of it and look forward to each new one.
Hi Sir,
i have error Run-time error '287: Application-defined or object-defined error. When I select "Debug"
"send"
.send
Thank you so much for the comprehensive clarification, in the attachment section, how if we would to attached a report in the access itself, instead of selecting a file ??
Steve, these videos are incredibly helpful! I am very grateful. You reference another video where you show how to put a PDF inside of Access. Mind sharing a link? Thanks again, the amount of time you put into these videos shows, and thanks again for the great tutorials!
Thanks for the vid. Any chance on doing a vid on Incoming/received outlook emails = how to get them into Access...Keep up the great work. Really loved your howto on setting up an SQL server
Thank you Steve you've demonstrated the best! Could you please include a video on how to include the outlook signature at the end of the email and i'm thinking is it possible to grab the data from a report and paste in the body? Thanks so much for your help
Dear do u plz tell me how to get data from electronic weigh machine to Access data base. Waiting for ur reply.
Hi Steve, thank you for your exposure in this topic.
My question here is how can I send an email with one field hidden. That is, I want when I am sending an email from my Access App, the form should copy the mac address of the send without the knowledge of the sender.
I just want whenever an email is sent to me, It should contain the MAC address of the sender to me without the knowledge of the sender. Is this possible?
Great video Steve. I just want to ask a stupid question could you please show how to add form1 with all the button browse, clear, and send. thanks
Hello Sir. I know this is an older video so I hope you'll get this message. I took the form1 and put it in my DB. Im running access 2016 and seem to get a application defined or object defined error at the oEmail.send part of the code. Additionally I am using the adjusted code from video number 27 because I think it'll fit my needs best. Any change you can coach me through this?
Hello,I don't want to add the attachment, instead I want the data in the form (Including the Textbox & Label) to be generated in the body of the outlook with table format. Is that possible?
How can I send an access report like an attachment with this code ?
I have created a data entry form with Subject line (Text), Email Body (Text) and an Ole Object box in which I paste the screen shot. Now on save button click, data gets added to the table and also drafts an email with the same subject line and email Body.
***CONCERN I am facing with the ole object IMAGE, which I want automatically to be in the email body below the text. Is there any way to do so, if not then any alternative or suggestions?
Great work Steve ! Please in what video did you create the Clear, Brows and Send button in the form?
Great work again Steve. Only wish is that you could take the integration of outlook further, like how to format the body text to allow inclusion of graphics and formatted text from perhaps a word template. I regularly send emails from within Access to club members using a store of pre-defined templates but cannot find a method of including the clubs logo and buttons with hyperlinks embedded. I currently open an email with the recipient's email address, subject and a greeting. Then copy and paste word template in the body of the e-mail a painfully slow operation when sending to 150 individuals. I have searched the web only to find that it "cannot be done in anything but plain text" unless I want to spend hundreds of $s on a specially designed programme. Please Help Steve, I'm sure you know how to achieve this.
Hi Steve, and thank you for this excellent video. I'm using your timer video and am able to auto send out an email using the timer logic which works beautifully combining this email logic with the timer logic...:) If I may trouble you however: How would I automatically open and attach a single report within my access reports as an attachment as opposed to browsing to a folder and attaching a document? Can this be done? I look forward to hearing from you. My Best, YelirNoed.
this was excellent thank you. I generate about 300 statements from an access application I created. I have code that filters statements to be sent by postal mail and statement to be emailed only. Now the email only list is getting large. when I run the report their are many email only statement. I would like to create a routine that would convert the many statements for each customer generated in one report to a pdf then email each one to the associated email address for that customer and run as a batch. Any ideas?
Question, I am running Access 2016, I used the send email code, but I get the "Compile Error: User-defined typed not defined" in reference to Dim oApp As New Outlook.Application... Can you help me with this? thanks
Can you attach a FILTERED report to an email using this method?
Hi Sir, I'm trying to send a an email to customer. The email is exactly the report which have an attachment in it. I want to use the report content for the email body, and automatically attach the attachment in the report into to email attachment and then send. I really appreciate any help!
Thank you.
Hi Steve, Instead of a path to a file attachment, is there a way to attach an Access Query in Excel format? I tried using DoCmd.SendObject and set the EditMessage Parameter to 'False' but it still opens the email and requires me to hit 'Send'. I just want it to send immediately. Must I save the excel/query file and use that path as you've done in this demo? Thanks in advance. Follow up, I did a DoCmd.OutputTo acOutputQuery for my query (which seems to work fine) and now I'm getting Error 287 (application-defined or object defined error). Code stops at the ".Send" line. I noticed if I mouse over the "oEmail.To" or "oEmail.Body" it shows the error text, but the "oEmail.Subject" shows the subject I entered.
Thanks for the video. I want to ask. Is there a way that you can send an invite to someone to add on both of your outlook calendars?
So, I put this in my database and i am getting question marks in front of the file path. e.g. "??C:\Documents\Attachment.pdf". I then get an error "Run-time error '-2147024773 (8007007b)': File name or directory name is not valid." Why is it placing question marks in my file?
how to use email protocol without depend on user outlook ? I meant can we use outlook from server or there are ways to do that ?
Hi All,
I need your help to create a macro,
I have an excel file in Outlook mail box, which need to be copied to MS Access. How can I get that?
Is there a way to do multiple attachments on an email? I’d like to send a pic and spreadsheet on one email as opposed to two separate ones. Thank you.
Hi Steve, how can we add signature to email based on default one created in outlook
can u pls share video to automatic generating mail to birthday people using ms access
I have a question , lets say I have the emails in tblWorkers , And I made a select query to select all the emails . Is there any way I can send an email to all these people ina press of a button , I dont want the user to write the emails in the To: box or to mess with any email addresses or anything so to speak , just one button that will send an email to all the email adresses selected in a query , is something like this possible, There is a paid add on for access but it costs 500$ , Inlighten me.
What if I have several email accounts in my outlook and I want to send from a specific account? How would I pull that off?
Hi Steve, I'm really enjoying all your MS Access courses. There's a lot of great information in them, and I find how you present it helps me understand it. Thanks !
Since you presented how to use Outlook mail from Access / VBA in this video it made me wonder if the rest of Outlook can be accessed (no pun intended) from Access / VBA.
Can I get or put entries in my Contacts ? Or read or update my Calendar ?
Yup. You can access contact, Calendar, tasks, etc.
Hello, thank you so much for your wonderful and useful videos. I followed your code but that gave me a run time error "invalid use of null" why do you think I got this error and you didn't?
Thank you Steve ! Great tips on how to integrate Outlook with Access. Can I make a suggestion , Is it possible to create, and most important, update a Outlook contact from a Access table ?
+Kazuo Ohashi Yes. You can use the MAPI namespace to find the contact and update it. This is VERY involved.
Would I be able to take this bit of code and throw it in to an application I'm working on in Visual Studio? I can't see why it would not work. my only question is what about authentication?
+Matthew Jones .NET and Access are not compatible.
SOLVED (changed registry key values)
This is the code i use to open outlook application and send a email for that current viewed customer.
It works fine but the only problem i have is that it opens outlook behind my access application and
it only comes foreward when i click on outlook.
i`ve tried different things with ".Display" / tried "OLApp.ActiveWindow.Activate", but it doesnt seem to work.
What can i do ???
-------------------------------------------------------------------
Sub Sendemail()
Dim oOutlook As Outlook.Application
Dim oEmailitem As mailitem
On Error Resume Next
Err.Clear
Set oOutlook = GetObject(, "Outlook.application")
If Err.Number 0 Then
Set oOutlook = New Outlook.Application
End If
Set oEmailitem = oOutlook.createitem(olMailitem)
With oEmailitem
.To = [Emailadress]
.Display
End With
Set oEmailitem = Nothing
Set oOutlook = Nothing
--------------------------------------------------------------------
Private Sub Knop427_Click()
Call Sendemail
End Sub
Instead of using the Browse button - and I wanted to attach a report from within the database (as a default) - how do I find the path of the report?
+Katrina Smith You could first save the report as a file, save the filename in a variable, and replace the attachment value with the filename variable.
great video, with the email textbox, can i paste an email address, for example 10 +, i think i could i may have to make the textbox bigger to be able to see some of the emails in the textbox.
You can.
sir, can we send sms from ms access?
Hi Steve, the codes work via Outlook 2013 and not Outlook 2016. I have set the reference to Outlook 2016 Library. Any help you could provide would greatly be appreciated. Thanks!
I am facing the same issue. Can anyone help please
Hi Steve, I have created an app with access that uses this send email with outlook. I built the app in office 16 and it works without any issues. However, when opened with office 13 there is an error with the vb. The outlook reference is turned on with the 13 version. Any suggestions?
So, it seems that Outlook references in vb are not backward compatible... Currently, if I need to make any changes in with the vb, I have to open the app and save it in office 13 to work with both versions.
im getting a "user-defined type not defined" error on the line : Dim fileDiag As FileDialog
+UA-cam Tube Sounds like you're missing a reference.
If Len(Me.txtAttachment) > 0 Then
oEmail.Attachments.Add Me.txtAttachment.Value
End If
i cannot debug it with .value
is there any code need to be done before use?
Instead of len(me.txtattachment) > 0, do If Not IsNull(me.txtAttachment) then. You should also use a File System Object to check if the file exists before attaching it.
Hello Steve, I'm recently working with Access to program a small application for production purposes, where a person fills the blank spaces and then sends a requisition to the department. When they click on a button (Save button) this one generates an automatic mail response to the applicant and the responsible to attend the issue. My doubt is that the email body is not being sent correctly, I'm using this part of the code to send the body: (Email_Body = Me.APLICANT.Column(1, Me.APLICANT - 1) & " ha solicitado un cambio de ingeniería en: " & Me.PART_NUMBER & Chr(13) & Me.DESCRIPTION.Text) where every variable is correctly defined but when you open the mail it has no body, the code shows no mistake either...
I wonder what do you think about this issue?
+Luis Valenzuela What happens if you take the variables out?
+Programming Do you mean the ones that are defined at the beginning of the subform for the Save button?
+Luis Valenzuela Anything that refers to a value which is retrieved from the form. As in, what happens when you try to send the email as just text that you write up as a string.
Hi Steve, your videos are a great help to me. I have implemented the vba for sending an email from Access 2010 but I must have Outlook open else I get the error message "Application-defined or object-defined error" when the code reaches this line of code : "oEmail.Recipients.Add v_email_in" where v_email_in is the email address. I am missing something in the code?
Steve, I get the same result using early or late binding. Thanks
It is too difficult to know based on your message. My best guess is you need to make sure the email address is a string.
Steve, I am getting errors with your code. I have screen clips to send you. Can you reply to me so I can send them? I have subscribed.
i want send a querey in boduy mail?? how
Thanks for the useful information.
can I open a saved .msg file (saved e mail) and reply to it through Access ?
You can, but that's a bit beyond the scope of any of my courses, and there's not a lot of requests for something this specific.
So when I hit "Send", I get a Run-time error '287: Application-defined or object-defined error. When I select "Debug", it highlights "If Not IsNull(.To) And Not IsNull(.Subject) And Not IsNull(.Body) Then"
It's getting frustrating because I even downloaded the code and copied it just to make sure I didn't put in an extra space and it still gives me the same error.
Are you sure you're inside of a With block?
Private Sub btnSend_Click()
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Set oEmail = oApp.CreateItem(olMailItem)
oEmail.To = Me.txtTo
oEmail.Subject = Me.txtSubject
oEmail.Body = Me.txtBody
If Len(Me.txtAttachment) > 0 Then
oEmail.Attachments.Add Me.txtAttachment.Value
End If
With oEmail
If Not IsNull(.To) And Not IsNull(.Subject) And Not IsNull(.Body) Then
.Send
MsgBox "Email Sent!"
Else
MsgBox "Please fill out the required fields."
End If
End With
oEmail.Send
End Sub
@@WVUTOAD1 Have you solve this problem, I also got the same error. Please tell me if you got solved.
How Can I populate the .to field with data from an existing form? And can I use it to open an existing custom form template in outlook that I have created already?
+Raise Your Kids Healthy By Nathani Clinic just set the to property to the value from the textbox.
using openargs, then onopen event me.to = me.openargs
Hi Steve,
Can you teach me how to create automatic email sender in access? I want it to send email through outlook automatically
Isn't that what this video teaches you?
Not really. I want it to open outlook by itself and send a general email to like multiple people. Like an automated reminder email for overdue tasks or such.
Programming I would appreciate it though
So add multiple emails in the oEmail.To. As for automated tasks, watch my video on how to use a timer. ua-cam.com/video/dIJXFmxCMts/v-deo.html
Awesome video. I figured out everything. But I have one more issue. After the email is being written, I run command ".Display" so I can review the email and see if it is being run properly, but my signature happens to get lost. I have a signature on my outlook that would pop up with a new message. Is there a way I could run a command that would bring my signature back again with out me trying to rewrite it as a string?
Sir how to send Sms to Students Parents By Mbile ???
Hi sir, what if i want to assign some of field on the body of the email, then how can i do it? Thanks
+Migueljr Enriquez I'm not really sure what you're asking.
Hi, what if the end users have different versions of Office. Let's say 2010, 2013 and 2016. Thanks
Then you will want to use late binding.
Doesn't work with Access 2007 for some reason.
+Manos Smar What kind of error are you getting? At what point doesn't it work?
+Programming I get an "Application-defined or object-defined error.
Where can I send you a screen shot?
+Manos Smar I suggest doing a screen shot and posting it to imgur, then post the link here.
+Programming imgur.com/LgpL4Wm
Ok, change the IsNull(.To) to IsNull(me.txtTo) assuming your textbox with the emails to send it to is called me.txtTo.
very good thank you very much but please if posible then also paste codes for us
The code is in the work files. There's a link in the description.
+Programming thank you welldone plz also guide about php and html plz
I mean, how can I send an access report attachment with this code ?