SendObject problem (1 Viewer)

sulaco

New member
Local time
Today, 16:48
Joined
Apr 12, 2011
Messages
1
Hello,

I am new to this forum but looking for help. Our section has been upgrading from XP to W7. There are numerous databases that had to be upgraded. Almost all have been done with little problem but I do have one that has become a bit sticky. I have gotten most of it working except for one are. One of the processes the db does is to extract certain data, put it to an excel file, attach it to an email, and send it. This part does not want to cooperate. I get the error: Method or data member not found.
In the vb the cursor highlights in blue .Update at the line: MAPIMessage.Update

above that highlighted in yellow is:
Public Sub SendObject(Optional ObjectType As Access.AcSendObjectType = acSendNoObject, _
Optional ObjectName, _
Optional OutputFormat As accSendObjectOutputFormat, _
Optional EmailAddress, _
Optional CC, _
Optional BCC, _
Optional Subject, _
Optional MessageText, _
Optional EditMessage)


The entire sub is:

Public Sub SendObject(Optional ObjectType As Access.AcSendObjectType = acSendNoObject, _
Optional ObjectName, _
Optional OutputFormat As accSendObjectOutputFormat, _
Optional EmailAddress, _
Optional CC, _
Optional BCC, _
Optional Subject, _
Optional MessageText, _
Optional EditMessage)


Dim strTmpPath As String * 512
Dim sTmpPath As String
Dim strExtension As String
Dim nRet As Long
StartMessagingAndLogon
Set MAPIMessage = MAPISession.Outbox.Messages.Add
If ObjectType <> -1 Then
If IsMissing(ObjectName) Or IsMissing(OutputFormat) Then
MsgBox "The object type, name, or output format is invalid. Unable to send message.", vbCritical
MAPISession.Outbox.Messages.Delete
GoTo accSendObject_Exit
Else
strExtension = GetExtension(OutputFormat)
nRet = GetTempPath(512, strTmpPath)
If (nRet > 0 And nRet < 512) Then
If InStr(strTmpPath, Chr(0)) > 0 Then

sTmpPath = RTrim(Left(strTmpPath, InStr(1, strTmpPath, Chr(0)) - 1))
End If
strFileName = sTmpPath & ObjectName & strExtension
End If
On Error Resume Next
DoCmd.OutputTo ObjectType, ObjectName, GetOutputFormat(OutputFormat), strFileName, False

If Err.Number = 0 Then
Set MAPIAttachment = MAPIMessage.Attachments.Add
With MAPIAttachment
.Name = ObjectName
.Type = CdoFileData
.Source = strFileName
End With
Kill strFileName

Else
MsgBox "The object type, name, or output format is invalid. Unable to send message.", vbCritical
MAPISession.Outbox.Messages.Delete
GoTo accSendObject_Exit
End If
End If
End If

If Not IsMissing(EmailAddress) Then
reciparray = Split(EmailAddress, ";", -1, vbTextCompare)
ParseAddress CdoTo
Erase reciparray
End If
If Not IsMissing(CC) Then
reciparray = Split(CC, ";", -1, vbTextCompare)
ParseAddress CdoCc
Erase reciparray
End If

If Not IsMissing(BCC) Then
reciparray = Split(BCC, ";")
ParseAddress CdoBcc
Erase reciparray
End If

If Not IsMissing(Subject) Then
MAPIMessage.Subject = Subject
End If

If Not IsMissing(MessageText) Then
MAPIMessage.TextBody = MessageText
End If

If IsMissing(EditMessage) Then EditMessage = True

MAPIMessage.Update
MAPIMessage.Send savecopy:=True, ShowDialog:=EditMessage

accSendObject_Exit:
'Log out of the MAPI session
MAPISession.Logoff
Set MAPIAttachment = Nothing
Set MAPIRecipient = Nothing
Set MAPIMessage = Nothing
Set MAPISession = Nothing
Exit Sub
End Sub

Any help would be greatly appreciated. Note: This worked in Access 2003
 

Users who are viewing this thread

Top Bottom