Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Automatically Sending Emails from Access


Message #1 by "Pritesh_b" <pritesh_b@t...> on Tue, 27 Nov 2001 10:44:13 -0000
This is a multi-part message in MIME format.



------=_NextPart_000_0032_01C17730.7420D990

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Hi



I have created a basic insert ASP program where users (friends) can 

insert some information. 



I wanted to know if there is a way of generating a email from Access 

when a new entry has been inserted?



If this is possible what other things do I require for it to work i.e. 

email server?



Please advise



Thanks



Pritesh






Message #2 by kyle_gaynor@b... on Tue, 27 Nov 2001 07:21:51 -0500

if (you use exchange it is simple.) then

     look at the "Sendto" object .

     it used exchange , outlook web email

  else

     is you are using notes goto this address.

     http://www.fabalou.com/

end if





Thank You,

Kyle Gaynor

213-4059







This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If
you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information
contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please
immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.



Message #3 by "Pritesh_b" <pritesh_b@t...> on Tue, 27 Nov 2001 16:07:34 -0000
Hi



Thanks for the information however i am using neither .. Is there any other

freebees?

----- Original Message -----

From: <kyle_gaynor@b...>

To: "Access" <access@p...>

Sent: Tuesday, November 27, 2001 12:21 PM

Subject: [access] Re: Automatically Sending Emails from Access





>

> if (you use exchange it is simple.) then

>      look at the "Sendto" object .

>      it used exchange , outlook web email

>   else

>      is you are using notes goto this address.

>      http://www.fabalou.com/

> end if

>

>

> Thank You,

> Kyle Gaynor

> 213-4059

>

>

>

> This transmission may contain information that is privileged, confidential

and/or exempt from disclosure under applicable law. If you are not the

intended recipient, you are hereby notified that any disclosure, copying,

distribution, or use of the information contained herein (including any

reliance thereon) is STRICTLY PROHIBITED. If you received this transmission

in error, please immediately contact the sender and destroy the material in

its entirety, whether in electronic or hard copy format. Thank you.

>

>




>



Message #4 by "John Ruff" <papparuff@c...> on Tue, 27 Nov 2001 08:25:10 -0800
I didn't get your very first message so I'm not sure what your asking,

but here is code for using Outlook to send email.  This program works

very well as I have incorporated it in many of my projects. (Courtesy

Microsoft's Auto97.exe file from their knowledgebase)



Creating and Sending a Message



This example demonstrates how to use Automation to create and send a

Microsoft Outlook message.  The procedure accepts two arguments.  The

DisplayMsg argument is required and if set to True, then Microsoft

Outlook is displayed with the completed message ready for the user to

send.  If set to False, the message is sent without displaying Microsoft

Outlook.  The AttachmentPath argument is optional.  This argument

accepts a path to a file which will be attached to the message before

sending.



Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)

    Dim objOutlook As Outlook.Application

    Dim objOutlookMsg As Outlook.MailItem

    Dim objOutlookRecip As Outlook.Recipient

    Dim objOutlookAttach As Outlook.Attachment

    

    ' Create the Outlook session.

    Set objOutlook = CreateObject("Outlook.Application")

    

    ' Create the message.



    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    

    With objOutlookMsg

         ' Add the To recipient(s) to the message.

         Set objOutlookRecip = .Recipients.Add("Nancy Davolio")

         objOutlookRecip.Type = olTo

        

         ' Add the CC recipient(s) to the message.

         Set objOutlookRecip = .Recipients.Add("Michael Suyama")

         objOutlookRecip.Type = olCC

        

        ' Add the BCC recipient(s) to the message.



         Set objOutlookRecip = .Recipients.Add("Andrew Fuller")

         objOutlookRecip.Type = olBCC

        

        ' Set the Subject, Body, and Importance of the message.

        .Subject = "This is an Automation test with Microsoft Outlook"

        .Body = "This is the body of the message." & vbCrLf & vbCrLf

        .Importance = olImportanceHigh  'High importance

        

        ' Add attachments to the message.

        If Not IsMissing(AttachmentPath) Then



            Set objOutlookAttach = .Attachments.Add(AttachmentPath)

        End If

        

        ' Resolve each Recipient's name.

        For Each objOutlookRecip In .Recipients

            objOutlookRecip.Resolve

        Next

        

        ' Should we display the message before sending?

        If DisplayMsg Then

            .Display

        Else

            .Send

        End If



    End With

    Set objOutlook = Nothing

End Sub



MAP code again courtesy Auto97.exe from Microsoft

Using Automation to Send a Microsoft MAPI Message



There are five main steps in sending a MAPI message through Automation:





.	Initializing and logging onto the MAPI session

.	Creating a new message and adding it to the Outbox

.	Adding the recipients (To, CC, and BCC) and resolve names

.	Setting valid properties, such as text, subject, and importance

.	Sending the message



   '-------------------------------------------------------------------

   ' This procedure sets an object variable to the MAPI Session object

   ' using the CreateObject() function. Then, it logs on to the session

   ' using a predefined profile. Once logged on, the procedure creates

   ' a new message and adds it to the Messages collection of the user's

   ' OutBox. Then, it creates two recipients (one on the TO: line and

   ' one on the CC: line) and adds both to the Recipients collection



   ' of the message. Next, it resolves the names of all recipients.

   ' Then, it attaches a sample file before filling in the Subject,

   ' Text, and Importance attributes of the message.

   '-------------------------------------------------------------------

    Sub SendMAPIMessage()

        Dim MapiSession As Object

        Dim MapiMessage As Object

        Dim MapiRecipient As Object

        Dim MapiAttachment As Object



        Dim Recpt

        Dim errObj As Long

        Dim errMsg



        On Error GoTo MAPITrap

        ' Create the MAPI Session.

        Set MapiSession = CreateObject("Mapi.Session")



        ' Log on to the session. If the ProfileName argument is 

        ' omitted, Microsoft Exchange prompts you for the profile to

        ' use. If the profile name is incorrect, you will receive a 

        ' runtime error.



         MapiSession.Logon profilename:="Steven Buchanan"



        ' Add a message to the Outbox.

        Set MapiMessage = MapiSession.Outbox.Messages.Add



        ' Add the recipients of the message. Note, each recipient must 

        ' be added separately to the Recipients collection of the 

        ' Message object.



        With MapiMessage

            Set MapiRecipient = MapiMessage.Recipients.Add

            MapiRecipient.Name = "Nancy Davolio"



            MapiRecipient.Type = mapiTo

            Set MapiRecipient = MapiMessage.Recipients.Add

            MapiRecipient.Name = "Andrew Fuller"

            MapiRecipient.Type = mapiCc

            Set MapiRecipient = MapiMessage.Recipients.Add

            MapiRecipient.Name = "Michael Suyama"

            MapiRecipient.Type = mapiBcc



            ' Resolve each recipient's e-mail name.

            For Recpt = 0 To .Recipients.Count - 1



                .Recipients(Recpt).Resolve showdialog:=False

            Next



            ' Attach a file to the message.

            Set MapiAttachment = MapiMessage.Attachments.Add

            With MapiAttachment

                .Name = "Customers.txt"

                .Type = mapiFileData

                .Source = "C:\Examples\Customers.txt"

                .ReadFromFile filename:="C:\Examples\Customers.txt"

                .position = 2880



            End With



            ' Assign the text, subject, and importance of the message.

            .subject = "My Subject"

            .Text = "This is the text of my message." & vbCrLf & vbCrLf

            .importance = mapiHigh



            ' View the message in Microsoft Exchange before sending. 

            ' Set the ShowDialog argument to False if you want to send 

            ' the message without viewing it in Microsoft Exchange.



            .Send showdialog:=True

        End With

        Set MapiSession = Nothing  ' Clear the object variable.



    MAPIExit:

        Exit Sub



    MAPITrap:

        ' Strip out the OLE automation error.

        errObj = Err - vbObjectError



        Select Case errObj

            Case 275       ' User cancelled sending of message.

                Resume MAPIExit

            Case Else



                errMsg = MsgBox("Error " & errObj & " was returned.")

                Resume MAPIExit

            End Select

    End Sub



If you want to send messages automatically at a certain period each day,

use the Windows Task Scheduler and use Help in Access and look up

Startup command-line options.  Typically I use the command-line option

/cmd to automatically start an Access program, run the program, then

close it.





John Ruff - The Eternal Optimist :-)







-----Original Message-----

From: Pritesh_b [mailto:pritesh_b@t...] 

Sent: Tuesday, November 27, 2001 8:08 AM

To: Access

Subject: [access] Re: Automatically Sending Emails from Access





Hi



Thanks for the information however i am using neither .. Is there any

other freebees?

----- Original Message -----

From: <kyle_gaynor@b...>

To: "Access" <access@p...>

Sent: Tuesday, November 27, 2001 12:21 PM

Subject: [access] Re: Automatically Sending Emails from Access





>

> if (you use exchange it is simple.) then

>      look at the "Sendto" object .

>      it used exchange , outlook web email

>   else

>      is you are using notes goto this address.

>      http://www.fabalou.com/

> end if

>

>

> Thank You,

> Kyle Gaynor

> 213-4059

>

>

>

> This transmission may contain information that is privileged, 

> confidential

and/or exempt from disclosure under applicable law. If you are not the

intended recipient, you are hereby notified that any disclosure,

copying, distribution, or use of the information contained herein

(including any reliance thereon) is STRICTLY PROHIBITED. If you received

this transmission in error, please immediately contact the sender and

destroy the material in its entirety, whether in electronic or hard copy

format. Thank you.

>

>

> ---

> You are currently subscribed to access as: pritesh_b@t... To



> unsubscribe send a blank email to $subst('Email.Unsub')

>





---

You are currently subscribed to access as: papparuff@c... To

unsubscribe send a blank email to $subst('Email.Unsub')



Read the future with ebooks at B&N

http://service.bfast.com/bfast/click?bfmid=2181&sourceid=38934667&catego

ryid=rn_ebooks








  Return to Index