email from access 97
#3
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
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
Thread
Thread Starter
Forum
Replies
Last Post