Tech Support Guy banner
Status
Not open for further replies.

Solved: Using VisualBasics to use the MailTo function

2K views 14 replies 3 participants last post by  maxx_eclipse 
#1 ·
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.
 
See less See more
#3 ·
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 ·
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.
 
#6 ·
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 ·
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 ·
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.
 
#12 ·
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top