ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   email from access 97 (https://www.scoobynet.com/computer-and-technology-related-34/218927-email-from-access-97-a.html)

Carl Harvey 11 June 2003 04:55 PM

Trying to automate a job in access and it needs to send a confirmation email when finished.

Anyone have any code to do this?

ChrisB 11 June 2003 05:04 PM

Yes thanks ;)

ChrisB 11 June 2003 05:06 PM

Being more helpfull - I originaly got this code from MS:

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:="Microsoft Outlook"

' 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 = Forms!frmMemberDetails!EMAIL
'MapiRecipient.Type = mapimessag


' Resolve each recipient's e-mail name.
' Starting with Outlook version 8.03 (ref. Q172623)
' OLE Messaging 1.0 was replaced with Active Messaging 1.1.
' Outlook 98 (version 8.5) replaced Active Messaging
' with Microsoft CDO (Collaborative Data Objects) 1.21.
' OLE Messaging 1.0 uses a zero-based Recipients collection;
' Active Messaging 1.1 and Microsoft CDO 1.21 are 1-based.
For Recpt = 1 To .Recipients.Count
.Recipients(Recpt).Resolve showdialog:=False
Next
'.Subject = "MCC"
.Send showdialog:=True
End With
Set MapiSession = Nothing ' Clear the object variable.

MAPIExit:
Exit Sub

MAPITrap:
errObj = Err - vbObjectError ' Strip out the OLE automation error.
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

Carl Harvey 06 November 2003 05:07 PM

Thanks chris

[Edited by Carl Harvey - 6/11/2003 5:07:56 PM]


All times are GMT +1. The time now is 08:09 PM.


© 2024 MH Sub I, LLC dba Internet Brands