Outlook Problem

samonwalkabout

Registered User.
Local time
Today, 13:41
Joined
Mar 14, 2003
Messages
185
I know this comes up a lot and i have looked through the past threads and at the microsoft site but i just cant get this to work. the code runs and produces an outlook box with all the appropreate bits filled in but its produce's an error on click of the send button. When trting to save the message it come up with 'some of the parameter values are invaild'. Could this be the problem with sending too??? Any help would be great

here's the module code

Sub Sendmessage(DisplayMsg As Boolean, 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 recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add([Forms]!![People] & vbCrLf & vbCrLf)
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add([Forms]![Email]![ccmail] & vbCrLf & vbCrLf)
objOutlookRecip.Type = olCC

' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add([Forms]![Email]![bccmail] & vbCrLf & vbCrLf)
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = [Forms]![Email]![Action] & vbCrLf & vbCrLf
.body = [Forms]![Email]![Action] & vbCrLf & vbCrLf
.Importance = olImportanceLow 'low 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
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom