Hi StefanK
I do use Outlook2003 and within my db I have created a seperate form to email.
Perhaps this wil suit your need. I do not face any kind of trouble for some
time using this script.
Good Luck
Greetings Harry
**** begin code ****
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
' Dim objOutlookReplyTo As Outlook.Recipients
Dim objOutlookAttach As Outlook.Attachment
StrBody = Me!EmailBody
strSubject = Me!EmailSubject
strAddressTO = Me!EmailAddressTO
strAddressCC = Me!EmailAddressCC
strBCC1 = "(e-mail address removed);"
strBCC2 = "(e-mail address removed)"
strAddressBCC = strBCC1 & strBCC2
strAddressReply = "yourAddress used by send on behalf"
On Error GoTo ErrorMsgs
'Stop procedure when e-mail has been marked as sent.
If Me!Emailsend = True Then
MsgBox "Mail has been sent already", vbInformation, "ERROR"
Exit Sub
End If
If Me!EmailUrgent = False Then strImportance = olImportanceNormal
If Me!EmailUrgent = True Then strImportance = olImportanceHigh
If IsNull(Me.EmailSubject.Value) = True Then
MsgBox "Het onderwerp is niet ingevuld", vbInformation, "ERROR"
Exit Sub
ElseIf IsNull(Me.EmailBody.Value) = True Then
MsgBox "Er is geen text geschreven", vbInformation, "ERROR"
Exit Sub
End If
If Me!Sender.Value = 1 Then
strSender = "your mail address1"
ElseIf Me!Sender.Value = 2 Then
strSender = "your mail address2"
Else
MsgBox "No sender selected", vbInformation, "ERROR"
Exit Sub
End If
strRegards = vbCrLf & vbCrLf & "with kind regards,"
StrBody = StrBody & strRegards
'Save Record voor verzending
DoCmd.RunCommand acCmdSaveRecord
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' adding strAddressTO.
' .To = (strAddressTO)
Set objOutlookRecip = .Recipients.Add(strAddressTO)
objOutlookRecip.Type = olTo
' Adding the CC en BCC recipient(s) to the message.
If Not IsNull(Me!EmailAddressCC) Then
Set objOutlookRecip = .Recipients.Add(strAddressCC)
objOutlookRecip.Type = olCC
End If
If IsNull(Me!EmailAddressBCC) Then
Set objOutlookRecip = .Recipients.Add(strAddressBCC)
objOutlookRecip.Type = olBCC
End If
' Set the Subject, Body, and Importance of the message".
If Not IsNull(Me!EmailBody) Then .Body = StrBody
If Not IsNull(Me!EmailSubject) Then .Subject = strSubject
' select importance high
.importance = strImportance
' select delivery receipt
.OriginatorDeliveryReportRequested = (Me.EmailDeliveryRequest.Value)
.ReadReceiptRequested = (Me.EmailReadRequest.Value)
' using the send on behalf
.SentOnBehalfOfName = "(e-mail address removed)"
'Instellen van de het reply adres.
.ReplyRecipients.Add (strAddressReply)
' below objOutlookMsg.Display means display the mail before sending,
' to avoid sending immediately the command send has to be disabled to
objOutlookMsg.Display
' 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
' If Not objOutlookRecip.Resolve Then
' objOutlookMsg.Display
' End If
' Next
' .Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
Me!Emailsend = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "E-mail has been sent", vbInformation, "Header"
Exit Sub
ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail " & _
"addresses to send your message. For more information, " & _
"see the document at
http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp. "
Else
MsgBox Err.Number & " " & Err.Description
End If
End Sub
****end code****