C
ChrisBat
REPOST
I'm reposting this because I really, really need to figure
this out and don't want anybody to see it because the
message is down at the bottom. Thank you very, very much
to anyone who can help.
What I'm trying to do is build a form that will allow me
to link directly with Outlook. Below is the code that I
took from the Microsoft paper How to Use Automation to
Send a Microsoft Outlook Message Using Access 2000 (ID
209948). The code works splendidly, except for two small
glitches. (1) The code only seems to work testing it from
the immediate window. This just won't do. (2) I want the
information to be taken using a form, with the recipient,
subject and body to be text boxes; Importance to default
to Normal (I figured out this part); and Send and Attach
to be buttons, with the Attach button opening the Attach
Which File window. Does anybody have any ideas? I'm
running Access 2000 on a Windows NT 4.0 machine.
Thank you very, very much.
Chris
Option Compare Database
Option Explicit
Sub 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 reciepient(s) to the message
Set objOutlookRecip = .Recipients.Add("_____@____.com")
objOutlookRecip = .Type = olTo
' Add the CC recipient(s) to the message
Set objOutlookRecip = .Recipients.Add("_____@____.com")
objOutlookRecip = .Type = olCC
' Set the subject, body and importance of the message
.Subject = "_____________"
.Body = "_______________________"
.Importance = olImportanceNormal
' 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
End With
Set objOUtlookMsg = Nothing
Set objOutlook = Nothing
End Sub
I'm reposting this because I really, really need to figure
this out and don't want anybody to see it because the
message is down at the bottom. Thank you very, very much
to anyone who can help.
What I'm trying to do is build a form that will allow me
to link directly with Outlook. Below is the code that I
took from the Microsoft paper How to Use Automation to
Send a Microsoft Outlook Message Using Access 2000 (ID
209948). The code works splendidly, except for two small
glitches. (1) The code only seems to work testing it from
the immediate window. This just won't do. (2) I want the
information to be taken using a form, with the recipient,
subject and body to be text boxes; Importance to default
to Normal (I figured out this part); and Send and Attach
to be buttons, with the Attach button opening the Attach
Which File window. Does anybody have any ideas? I'm
running Access 2000 on a Windows NT 4.0 machine.
Thank you very, very much.
Chris
Option Compare Database
Option Explicit
Sub 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 reciepient(s) to the message
Set objOutlookRecip = .Recipients.Add("_____@____.com")
objOutlookRecip = .Type = olTo
' Add the CC recipient(s) to the message
Set objOutlookRecip = .Recipients.Add("_____@____.com")
objOutlookRecip = .Type = olCC
' Set the subject, body and importance of the message
.Subject = "_____________"
.Body = "_______________________"
.Importance = olImportanceNormal
' 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
End With
Set objOUtlookMsg = Nothing
Set objOutlook = Nothing
End Sub