Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

Solved: Using VisualBasics to use the MailTo function


(!)

maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
29-Jan-2009, 06:31 AM #1
Solved: Using VisualBasics to use the MailTo function
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.
Greg8537481665's Avatar
Greg8537481665 Greg8537481665 is offline
Junior Member with 21 posts.
 
Join Date: Jan 2009
Location: NY
Experience: Advanced
31-Jan-2009, 11:10 AM #2
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.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
31-Jan-2009, 11:49 AM #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?

Last edited by maxx_eclipse; 31-Jan-2009 at 12:18 PM..
Greg8537481665's Avatar
Greg8537481665 Greg8537481665 is offline
Junior Member with 21 posts.
 
Join Date: Jan 2009
Location: NY
Experience: Advanced
31-Jan-2009, 04:26 PM #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.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
01-Feb-2009, 10:03 PM #5
Quote:
Originally Posted by maxx_eclipse View Post
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?
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.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
01-Feb-2009, 10:20 PM #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

Last edited by maxx_eclipse; 01-Feb-2009 at 10:28 PM..
Greg8537481665's Avatar
Greg8537481665 Greg8537481665 is offline
Junior Member with 21 posts.
 
Join Date: Jan 2009
Location: NY
Experience: Advanced
01-Feb-2009, 10:28 PM #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.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
01-Feb-2009, 10:39 PM #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.
OBP's Avatar
OBP OBP is offline OBP is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 18,649 posts.
 
Join Date: Mar 2005
Location: UK
02-Feb-2009, 05:34 AM #9
See this Thread for an example database of emailing, it is in Access 2003 format but should still work for you.

http://forums.techguy.org/business-a...hyperlink.html
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
02-Feb-2009, 08:28 AM #10
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).

Last edited by maxx_eclipse; 02-Feb-2009 at 08:35 AM..
OBP's Avatar
OBP OBP is offline OBP is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 18,649 posts.
 
Join Date: Mar 2005
Location: UK
03-Feb-2009, 10:45 AM #11
Sorry, wrong Thread, this one has the code in it.
http://forums.techguy.org/business-a...-e-mail-2.html
Greg8537481665's Avatar
Greg8537481665 Greg8537481665 is offline
Junior Member with 21 posts.
 
Join Date: Jan 2009
Location: NY
Experience: Advanced
03-Feb-2009, 08:11 PM #12
Ok...this seems to be what you want...great part is its a video tutorial and there is plenty of them.

http://www.wonderhowto.com/how-to/vi...k-2007-239804/


I used access 2007 as well but perhaps I am a bit old school, I always used disconnected architecture and always code my own routines..I do not like using built-in functionality stemming form add-ins or references..for compatibility reasons.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
04-Feb-2009, 12:06 AM #13
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.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
04-Feb-2009, 10:01 AM #14
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.
maxx_eclipse's Avatar
maxx_eclipse maxx_eclipse is offline
Computer Specs
Member with 291 posts.
THREAD STARTER
 
Join Date: May 2007
Location: http://127.0.0.1
Experience: Intermediate In Few Areas
05-Feb-2009, 09:00 AM #15
Solved it,

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

Access Programmers
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑