felix25 _http://msdn.microsoft.com/office/understanding/outlook/codesamples/default.aspx?pull=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp#odc_ac_olauto_introduction
В примере для Access, но думаю подойдет для любой програмы, использующей VBA.
[more=Sending an Outlook Mail Message Programmatically]Sending an Outlook Mail Message Programmatically
Create a sample text file named Customers.txt in the My Documents folder.
Start Access, and create a database named Automation.mdb.
Note The samples in this article use the Automation.mdb database that is included as a downloadable file with this article.
Create a module and type the following line in the Declarations section if it is not already there:
Option Explicit
On the Tools menu, click References.
In the References box, click to select the Microsoft Outlook 11.0 Object Library, and then click OK.
Note If the Microsoft Outlook 11.0 Object Library does not appear in the Available References box, do the following:
In Windows Control Panel, double-click Add or Remove Programs.
In the list of installed programs, select Microsoft Office 2003, and then click Change. Microsoft Office 2003 Setup starts in maintenance mode.
Click Reinstall or Repair, and then click Next.
Click Detect and Repair errors in my Office installation, and then click Install.
Click OK to close the References dialog box.
Type or paste the following VBA procedure in the new module:
Код: Sub sbSendMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
On Error GoTo ErrorMsgs
' 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. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "Last test." & 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
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
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