VBA for sending mail and saving it in a database

P

puntertips

HI All,

I would really appreciate if any once can assist me:
My requirement is:

A word document(which is actually a form contains name, country, age,
phone number) should have a submit button that when clicked should be
attached in a new mail in outlook 2007.
This document should also contain an button which when clicked should
stored all the information in a database ( preferred MS access) by
extracting the content from the document.

Your help is highly appreciated.

Thanks,
puntertips
 
D

Doug Robbins - Word MVP

For sending the document, here is the help from the Visual Basic Help file
for the MsoEnvelope.Item Property

MsoEnvelope.Item Property

Gets a MailItem object that can be used to send the document as an e-mail.
Read-only. expression.Item
expression Required. A variable that represents a MsoEnvelope object.

Example

The following example sends the active Microsoft Word document as an e-mail
to the e-mail address that you pass to the subroutine.

Visual Basic for Applications
Sub SendMail(ByVal strRecipient As String)

'Use a With...End With block to reference the msoEnvelope object.
With Application.ActiveDocument.MailEnvelope

'Add some introductory text before the body of the e-mail message.
.Introduction = "Please read this and send me your comments."

'Return a MailItem object that you can use to send the document.
With .Item

'All of the mail item settings are saved with the document.
'When you add a recipient to the Recipients collection
'or change other properties these settings will persist.

.Recipients.Add strRecipient
.Subject = "Here is the document."

'The body of this message will be
'the content of the active document.
.Send
End With
End With
End Sub


For extracting the data, take a look at the following article on Greg
Maxey's website:
http://gregmaxey.mvps.org/Extract_Form_Data.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

puntertips

Thanks,Doug Robbins.
I was able to follow the procedure for sending the mail... but
retriving the data from the mail( as described in the article link) is
not something that I understood..will check once again and will
provide the feedback..
But thanks once again for taking time to reply6 to my mail.
puntertips
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top