1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Using VisualBasics to use the MailTo function

Discussion in 'Software Development' started by maxx_eclipse, Jan 29, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Afternoon everyone,

    I'm crossing over from the Business Applications area to ask for help about a database I'm currently working on. I'm using Microsoft Access 2007 to make a database for a company that wants to keep all their clients contact details within. I have almost built everything that I need within my database, but now I'm stuck.

    I intend on providing a command that send an email to multiple recipients. The idea is that the recipients for the email are selected using a check box associated with the client.

    I checked MSDN for the specific code I need, and I came across the MailMessage.To object. According to the description, I believe that this is what i would need to use. But the problem is, I have no idea on how to use VBA. I installed Visual Basics 2008 Express Edition, so that if anyone could talk me through the code (or even possibly send the code), then I suppose I could try to understand how it works, so that I can replicate it to my database.

    I appreciate any help given.

    Thanks,

    Eugenio.
     
  2. Greg8537481665

    Greg8537481665

    Joined:
    Jan 30, 2009
    Messages:
    21
    IM a VBA expert so I can probably help. Here is code I used in ACCESS 2003: http://www.tek-tips.com/faqs.cfm?fid=537
    which worked fine. If this doesnt help let me know...ill check back in a couple days.
     
  3. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Just curious, if I only need to have the To: field, can I just copy that respectful part of the code? Or do I have to copy all of the code to make it work?

    Where it says to put in the code in the command button, do I do it in VBA? Does it do the same if it is entered into the Expression builder?

    quick one: I am not use to modules, does it work as a standalone object? Or do I attach it to a button as a command, or as an AutoExec sort of function?
     
  4. Greg8537481665

    Greg8537481665

    Joined:
    Jan 30, 2009
    Messages:
    21
    As you have a limited understanding of VBA I would recommend you follow the directions. Also, If you can use any code in more than one project it is better practice to use classes and modules than rewriting code every time. Also if you look at the code you will see it requires API so you must use a module, class, or out it at the top of your form. (forms are classes I am just trying to be clear).

    Once you have learned how it works....then add you own touches to it.
     
  5. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Still, where do I put the module? In the form as a hidden object? To be run by a macro? The page doesn't say what to do with it.
     
  6. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    I just got a compiler error for the first line of the VBA:

    Private Sub Command75_Click()

    I changed "Command0" to "Command75", because Command0 doesn't exist. So when I changed it to Command75 and tried running it, it didn't work. I changed all the Command numbers in the coding respectively, and I got a compiler error on the first line. :p
     
  7. Greg8537481665

    Greg8537481665

    Joined:
    Jan 30, 2009
    Messages:
    21
    Well (and I mean this as a tutorial not literally for those that know VBA)....A module is a code file that everything in your projct can share without declaring it with a dim statement. A class is like a module but you must declare it and every declaration contains its own copy of its variables. A Form, report, table, or view are a from of classes (aka object). A module you create the same way you would a form,table, view,etc. it is one of the options on the left side of your database container window(look for the word module..then click new on the top of the same container window). Alternatively you can go to insert...modules. As for where to put it...you dont have a choice...just add one.

    Also..by example....If you add a new module, be default it is named module1. Within module1 place the following code.....

    Public Sub MyTest()
    msgbox "Yes, another hello world!",vbokonly,"Some MessageBox Title"
    end sub

    then behind the command button of you form simple place the word
    MyTest

    Hope this helps..This is very basic...The best I can offer after this is to have you send me you project so I may look at it...along with some sample data....so I know specifically what you are dealing with..if necessary. I am Grs85374@yahoo.
     
  8. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Oh, I've probably forgot to mention.

    Because I've got Office 2007, my files are saved in the new Access formats (.accdb). And I can't convert the current project to an mdb format because one of the objects (I don't know which) contain a function that is only functional in Access 2007.
     
  9. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
  10. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    OBP,

    Had a look at the sample database, but it isn't what I am looking for.

    What I need is some piece of VBA coding that would send e-mails to the contacts in a list (maybe using an "If Not Null" command to apply to checked items).
     
  11. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
  12. Greg8537481665

    Greg8537481665

    Joined:
    Jan 30, 2009
    Messages:
    21
  13. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Hey, thanks for the link. Unfortunately, the net here is super slow today, so I'll have to check it at a later time.

    And hey, not blaming you for choosing to do things your way. ;)
     
  14. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Sorry Greg, but the video wasn't helpful. It was talking about data relation between Access and Outlook, but wasn't exactly about mass email functions.
     
  15. maxx_eclipse

    maxx_eclipse Thread Starter

    Joined:
    May 28, 2007
    Messages:
    291
    Solved it,

    I took some coding from another VBA command file I found on the internet:

    Access Programmers
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/795592