Dear Sir, Thank you very much this lesson. I have seen a bunch similars, but this is the greatest. Especially because you insert a loop which go through the recordset.
@javedahmed83433 жыл бұрын
Sir, I saw so many videos but this your video fetched me the desired output. Thanks a lot. May God bless you
@tommyd13765 жыл бұрын
This is exactly what I was looking for. Helped me out a lot. The only change I made was added a message box to verify email sent. Just a visual thing for me.
@walternascimento1255 Жыл бұрын
Congratulations! There were several searches and the only tutorial that really worked! Thanks
@stephenheusz32364 жыл бұрын
I wish I had found this months ago. I created a similar application but really struggled to understand what I was doing. Your explanations are very clear and now i feel as if I have actually learnt something, rather than just achieving something.
@maneasc81825 жыл бұрын
This is a great tutorial. Your explanations of the code structure was fantastic - Thank-you!
@sergeykozlov60235 жыл бұрын
Great! It works. Besides I learnt some tricks on Access from Guru in his careful explanation of the lesson. Thank you very much!
@queenlioness7056 Жыл бұрын
Thank you for this video. I will try it on my Access Database.
@ElderX22 жыл бұрын
Fantastic videos I am learning lot's of new things. Thank you.
@johnclark8517 жыл бұрын
Excellent video. I really like your technique on checking to see if other apps are open. I will be using that in all my apps as well. Thanks for posting!
@KeffelewAssefa2 жыл бұрын
Thank you, great tutorial.
@gdcdatabaseservices3 жыл бұрын
Thank you very much, this was excellent. Question, I have an MS Access Database for my customers that run in MS Access Runtime, and I want them to be able to send email just as you showed. I do not want the clients they are sending emails to, to reply back (block it) and I want it to show the email is coming from an alias from my main account. Saying that, is this the setup for sending emails I need?
@trooperstravels Жыл бұрын
Great work very easy to follow. If you have multiple email accounts in outlook how do you select a specific from email account? I've tried several different ways but can't seem to get it to work. I have to create the emails and not send immediately, manually change the from email address and send.
@davidgray92424 жыл бұрын
How can you define the email account from which the mail will be sent - does it always have to be only the default outlook account?
@codekabinettcomen4 жыл бұрын
You can use the SendUsingAccount property of the MailItem to define the account it is sent from. Here is an example: codekabinett.com/page.php?Theme=11&Lang=2#send-email-outlook-vba-sender-account
@TonyTony-dn2ir5 жыл бұрын
Beautifully explained. Liked, subscribed and notified.
@kiwikiki7187 жыл бұрын
Video is great. How do you add an attachment to the email if you have a field that includes the path?
@codekabinettcomen7 жыл бұрын
Thank you! To add an attachment is pretty simple. With outMail being an Outllok.MailItem, you add this line to the code to add an attachment from a path store in the recordset. outMail.Attachments.Add rs.Fields("FieldName_PathToAttachment").Value
@chriscline93812 жыл бұрын
How would you expand this to add an attachment?
@GamersRebirthDL6 жыл бұрын
You are the best! Thanks Bro! This video is Amazing and straightforward. Keep it up man and good luck! If u need any gaming emulator rom links lol let me know. 👍🤘😉
@szilviatoth39627 жыл бұрын
This is a really helpful video to vba beginners like me, it works! If I need to send a table or query result as xls attachment to outlook, what exactly should I add to the code and where? Thank you.
@codekabinettcomen7 жыл бұрын
If you want to send the same file to everybody its fairly easy. You first need to export the data to xls. To do that add these lines before you open the recordset with the email recipients. Dim fileName As String fileName = "c:\tmp\exportfile.xlsx" DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "yourTableOrQueryName", fileName Then you need to add the attachment to every outgoing email. To do that add this line somewhere between Set outMail = ... and outMail.Send. outMail.Attachments.Add fileName Done. It's more complicated to send a custom export file for each recipient. You would need to export the data inside the loop then and probably need to add criteria to the query to export only the records for that recipient. - That is beyond what can be explained in a comment. I'll probably make another video about this within the next couple of weeks.
@codekabinettcomen7 жыл бұрын
Changing the procedure from Sub to function does not affect what it does. The RunCode-Macro is a valid reason for doing so. I would recommend you double check your query with the email recipients. Does it contain you address multiple times?
@szilviatoth39627 жыл бұрын
I did not pull email address from a table like you, I was testing it only with my email address that I typed manually in the code. I found out that with removing the loop section, solves my problem. It was sent 3 times to my outlook because I have 3 records in my test table. Now everything is working perfectly even with runcode macro. Thanks for the help!!
@adrianapenaloza96195 жыл бұрын
hi! this is great. :) is there a way to send emails from a shared inbox? like on behalf of another account? thanks so much!
@codekabinettcomen5 жыл бұрын
Yes, if the other account is also configured in Outlook, you can send email from that account. Here is a explanation how to do it: codekabinett.com/page.php?Theme=11&Lang=2#send-email-outlook-vba-sender-account
@scottnorman22967 жыл бұрын
Great video, Thank you! Why do emails appear in outbox instead of sent mail?
@codekabinettcomen7 жыл бұрын
Because technically they are not sent yet. The get queued in the outbox for sending. When they are actually send depends on your Outlook configuration.
@andrewabaye66035 ай бұрын
Beautiful Video and it pointed me to exactly what I was looking for. If I want to attach report as PDF, what will my code be please?
@libingeorge21043 жыл бұрын
Hello Sir, When i am running the coding/ trying to send mail. there is one warning message coming before sending the mail. it is asking deny or allow message. to avoid this warning message what we can do.. ? please leave your valuable answer.
@crafty_tams5 жыл бұрын
Thank you so much for this fantastic video!
@mistyheyden4 жыл бұрын
How would we do this and send one email to multiple addresses?
@codekabinettcomen4 жыл бұрын
You can add multiple email addresses separated by commas to the To-property of the Mailitem. If you need to retrieve all those addresses from multiple records in a table you can take a look at this article for a possible solution: codekabinett.com/rdumps.php?Lang=2&targetDoc=access-vba-output-column-values-comma-separated
@chadighafari7763 жыл бұрын
Brilliant work! Thank you! Can I send the emails even if I have some addresses missing? ie 100 customers with 10 customers that don't have an email... Access bugs at the first "blank" fiel
@codekabinettcomen3 жыл бұрын
Just filter out customers without an email address in the query to get the recipients.
@johnwet57985 жыл бұрын
This is what the thing I want. Thanks
@stanTrX5 жыл бұрын
thanks, works smoothly.. do you think we should better use "clone" of the recordset, instead of the original? is there any difference on that?
@codekabinettcomen5 жыл бұрын
If you created the recordset explicitly for this purpose there is no point in using a clone of that recordset. A recordset clone is useful if you need multiple cursors on the same set of records. E.g. you use the recordset of a form for another purpose.
@stanTrX5 жыл бұрын
codekabinett.com/en many thanks
@stanTrX5 жыл бұрын
@@codekabinettcomen is it possible to trigger this module to a button in a form?
@codekabinettcomen5 жыл бұрын
Yes, sure. I would create an event procedure for the button and just call the routine to send emails from there.
@garycurtis3 жыл бұрын
Excellent Video, is there a way to have it send from an alias email address?
@codekabinettcomen2 жыл бұрын
Maybe this link can help: codekabinett.com/page.php?Theme=11&Lang=2#send-email-outlook-vba-sender-account
@birdgreen22564 жыл бұрын
Need your support to enclose a report attachment in your same code since I tried and I’ve got 2 separate outcomes sent email and the other is a display of the attachment .. please provide me the additional code if possible.
@codekabinettcomen4 жыл бұрын
Not sure what you are asking. Look at the .Send and .Display methods of the MailItem for sending or just displaying the email. Use .Save to save the message as draft.
@birdgreen22564 жыл бұрын
@@codekabinettcomen Thanks a lot, just I want to adjust the code in order to add attachments.
@aistedulkyte27912 жыл бұрын
Hi, I am trying your code and my code is not picking up data from Database. I checked a hundred times, database name is correct. Cannot understand what is wrong? Any chances that you can help? :)
@codekabinettcomen2 жыл бұрын
If there is no error but you are not getting the data you expect, there most likely is a problem with the query criteria you use. - Try to build your query in the visual query designer step by step, checking results after each. Finally, you can switch to SQL view in the query designer and copy the SQL over to VBA.
@ericclapton21504 жыл бұрын
I tried this on Office 365 with interesting results. when i run the code, it makes one pass through and sends the email perfectly. however, when it tries to repeat as part of the loop, when it gets to the "outmail.send' is throws an error "Outlook does recognize one or more names" and it highlights the "outmail.send". then quits Any Ideas?
@codekabinettcomen4 жыл бұрын
Any chance this only happens with an email recipient that has a comma in its name? There is setting in Outlook if the comma should be treated as separator in the recipient list of an email. This feature sometimes behaves inconsistently; e.g. for an completely unknown recipient it works but once Outlook knows the recipient it will reject the part delimited by the comma. - Try turning off that setting in Outlook.
@codekabinettcomen4 жыл бұрын
In any case, you can use the Recipients property of the Outlook MailItem to identify all recipients Outlook derived from the addresses of the email. There will be one that Outlook cannot resolve. If you know which it is it will probably reveal the root cause of the problem.
@ericclapton21504 жыл бұрын
@@codekabinettcomen No, that wasn't it. see my next comment
@ericclapton21504 жыл бұрын
@@codekabinettcomen Yes. this was the problem. a legit gmail address, without spaces or anything was the problem. to test, i used the same email for 4 names and the system sent out 4 emails. Now, can you help a newb one more time with the code i need to test recipient. i assume the results would be like an RS in that there would be a list of emails that were sent, is there also a list of failed? i looked here:docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.recipients but i don't know how to invoke the code for what i want. thanks again for the video and the help.
@codekabinettcomen4 жыл бұрын
Next comment? -[Edit] Found it. Was held for spam review. - Approved it.
@stanTrX5 жыл бұрын
is it possible to change the code to "html body format"?
@codekabinettcomen5 жыл бұрын
Yes, it is. Check out the BodyFormat and HTMLBody properties of the MailItem. I wrote a text on creating HTML email with VBA, which might be a helpful reference. codekabinett.com/rdumps.php?Lang=2&targetDoc=howto-create-html-email-access-vba-outlook
@adityabajaj63525 жыл бұрын
Brilliant and simple, can you please advise how to add a table in the email text?
@codekabinettcomen5 жыл бұрын
Thank you. To create a table in HTML you need to build the full table structure in the string. Most simple example: someValue - Look up these tags in an HTML reference.
@karagidesa3 жыл бұрын
Hello again, I am trying the command mailitem.attachments.add on the code, however it doesn’t work. Would it be possible to crarify the path? For example is it mailitem.Attachments.Add (“C:\test\broshure.pdf”), (.pdf) . Thank you very much in advance.
@codekabinettcomen3 жыл бұрын
Just use: mailitem.Attachments.Add "C:\test\broshure.pdf" The type argument is optional and not relevant in 99.9% of cases.
@karagidesa3 жыл бұрын
Great Video, very helpful! Please advice how could I include an image in the body of the text, and how could I attach a pdf file. Thank you very much indeed!
@codekabinettcomen3 жыл бұрын
Thank you for your feedback! Right now I've only a text explaining that: codekabinett.com/rdumps.php?Lang=2&targetDoc=howto-create-html-email-access-vba-outlook Your question was asked quite a lot. So, I think, I will also record a video on that topic. It will take a couple of weeks though, before that comes along.
@karagidesa3 жыл бұрын
@@codekabinettcomen Thank you very much, indeed!
@RAVIKUMAR-oc2lm4 жыл бұрын
Sir..the video is really great... But I have one doubt.. I have report which is same for each user(but updates along with the query) ...and I want to send it in PDF format for each of them..how can I achieve this?
@codekabinettcomen4 жыл бұрын
Good question. I'll probably address this in more detail in the future. Where are you struggling? I made a video on creating PDFs from reports. kzbin.info/www/bejne/Y6aqhYRmo7ijrLc That should cover part of your question. If you are using Outlook, you would need to add the PDF generated for each user with the Attachments.Add method of the MailItem. HTH
@Jihaoui5 жыл бұрын
very good , thank you
@lwazimace25083 жыл бұрын
Genius.
@kabal55204 жыл бұрын
Hi :) I have a question. I have to send information about certain amount of customers (name etc) to one recipent. Is it possible to send it in one message, instead of many?
@codekabinettcomen4 жыл бұрын
You need to add all the information for the email in a long String variable and then used that for the email text (Body).
@MmM-yo4kz4 жыл бұрын
Hi, thank you very much for your excellent code - it really works. However, when I change my query to updatable one which depends on a form (the query's criteria like ([Forms]![Users]![User_ID]) I get "Run-Time error '3061' Too Few parameters. expected 1". Could you please help me with it?
@codekabinettcomen4 жыл бұрын
The "too few parameters" error is usually caused by a mistyped column name or a similar error in the reference to your form control.
@MmM-yo4kz4 жыл бұрын
@@codekabinettcomen Thank you for quick response. This error appears only if I change any criteria of my query to updatable (as I said like ([Forms]![Users]![User_ID]). If the criteria is permanent (for instance, UserName - "Smith") it works. I don't change the code, I only change query parameters. And debug indicates when I hover "rs.Fields("FirstName").Value=.
@codekabinettcomen4 жыл бұрын
Then there is something wrong with the reference to the form control.
@MmM-yo4kz4 жыл бұрын
@@codekabinettcomen But the reference works when I run my query using the form. Could you try to make the query, which your code refers, updatable-depended on a form, and try to launch your code? Please help me, I am really struggling with this problem.
@codekabinettcomen4 жыл бұрын
Sorry, I think I missed part of the problem. When opening a recordset direct form control references cannot be resolved. You need to concatenate the SQL string with the value of the form control in VBA. This should be explained in this video: kzbin.info/www/bejne/mWPCl3iae6edlbM
@ivanvilches28904 жыл бұрын
First, thank you for the video and instructions, really easy to follow. Got it working perfectly! I am struggling to add a signature that has an image in it. I tried changing to HTML or calling the .htm signature from outlook… but I don’t get to work. Is there an easy way to add a signature with the image in this code? Thanks and advance and keep up the good work.
@codekabinettcomen4 жыл бұрын
To get an HTML email you need to prepare your HTML text and then set the HTMLBody property of the MailItem with your HTML text. Using the predefined signatures from Outlook is a bit of a pain. I would ignore them and also create the signature with your VBA code. I've got an older text on creating HTML emails with embedded images here: codekabinett.com/rdumps.php?Lang=2&targetDoc=howto-create-html-email-access-vba-outlook
@ivanvilches28904 жыл бұрын
@@codekabinettcomen Thank you for the quick response! I have been able to play a bit with changing the format to HTML and got it working, I will look at the info provided and will let you know how it turned out. Thank you and once again!
@birdgreen22564 жыл бұрын
when i run i do get >> Run-Time error '3061' Too Few parameters. expected 1
@codekabinettcomen4 жыл бұрын
Most likely there is a typing error in one of the field names of our SQL query.
@birdgreen22564 жыл бұрын
@@codekabinettcomen Yes you are right and I have solved it, really you are great .. thank you so much for your great support.
@birdgreen22564 жыл бұрын
Need another help .. I have a flied sentemail (Yes/No) And I want to change the value to true when we sent the email so that I don’t repeat sending same email to the same person again
@codekabinettcomen4 жыл бұрын
Just add this to the email send code and set the field to true. If your query is not updateable you need to execute an update query on the field.
@rajneeshrana42826 жыл бұрын
sir if i need an attachment in this. where i want to include data from a query.
@codekabinettcomen6 жыл бұрын
You need to export the query to an HTML file and attach the file to the email. If the data is different for each email you are going to need a temporary query for the export that is adjusted for each record. That query can be used in docmd.TransferText acExportHTML to export the HTML.
@minnal383 Жыл бұрын
Will this work with Access 2003?
@codekabinettcomen Жыл бұрын
I can't say for sure out of my head, but it very likely should do.
@jassimal-mansor82315 жыл бұрын
thanx a lot . I want to see the email before send it , I try to use docmd.openreport >>>> but it send to only one email not all
@BenjaminFernandini124494 жыл бұрын
Great
@christinachahin45593 жыл бұрын
Hi codekabinett.com/en, Your video is great! How could I modify the code so that if my table has multiple lines for one user, it could group them and send only one email to the person as opposed to an email per line? Thanks,
@codekabinettcomen3 жыл бұрын
You can sort the query by the email address and store the current email address in a VBA variable. You then concatenate all the text for the email from the recordset in a another variable and finally create and send the email only if a new email address is in the next record of the recordset.