Below is a sample of my code. I run this code as a module in ACCESS2000. The problem I am having is that the code works fine first shot in the morning. The second time I run it, the system locks. I have tried this on both WIN2000 and WIN98.
I would like to develop this into a loop so we can send dozens of automatic e-mails. However with the lockup problem, this is not practical.
Function SendMessage(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 recepient to the message
Set objOutlookRecip = .Recipients.Add([Forms]!
[forma]![frmSuba]![VendorEmail])
objOutlookRecip.Type = olTo
'Set Subject, Body and Importance of the message
.Subject = "Request for Info " & [Forms]![forma]!
[ReqNo]
.Body = "Please complete and return the attachment
before " & [Forms]![forma]![DueDate] & "." & vbCrLf &
vbCrLf & vbCrLf & vbCrLf & "Thank you." & vbCrLf & vbCrLf
.Importance = olImportanceHigh
'Add attachments to the message
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add
(AttachmentPath)
End If
'Kill attachment
Kill ("C:\My Documents\" + "info.doc"
.Send
' .Display
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
I would like to develop this into a loop so we can send dozens of automatic e-mails. However with the lockup problem, this is not practical.
Function SendMessage(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 recepient to the message
Set objOutlookRecip = .Recipients.Add([Forms]!
[forma]![frmSuba]![VendorEmail])
objOutlookRecip.Type = olTo
'Set Subject, Body and Importance of the message
.Subject = "Request for Info " & [Forms]![forma]!
[ReqNo]
.Body = "Please complete and return the attachment
before " & [Forms]![forma]![DueDate] & "." & vbCrLf &
vbCrLf & vbCrLf & vbCrLf & "Thank you." & vbCrLf & vbCrLf
.Importance = olImportanceHigh
'Add attachments to the message
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add
(AttachmentPath)
End If
'Kill attachment
Kill ("C:\My Documents\" + "info.doc"
.Send
' .Display
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function