Hi, I have an email sub procedure that sends an order as an attachment. However if the company does not exist in outlooks contacts then outlook opens and asks the user to select the recipient. I want to be able to test to see if the order was
sent or cancelled and output an appropriate message for either action.
access 2000 on win 98se
email :
B
sent or cancelled and output an appropriate message for either action.
access 2000 on win 98se
email :
Code:
Sub SendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.recipient
Dim objOutlookAttach As Outlook.Attachment
Dim supplier As Variant
supplier = recipient
' 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(supplier)
objOutlookRecip.type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("rob.morg@ihug.co.nz")
objOutlookRecip.type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Order"
.Body = "Please fill the attached order: " & 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
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
MsgBox " Your Order has been sent"
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
B