Emailing from Access

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Not sure if this is correct forum

Am looking to be able to set up routine to allow me to send emails from data
held in Access Query - either through outlook or some other third party
program.

Anyone anyu ideas as to best way to set this up please

Thanks

Alex
 
First off, and I'm not trying to be rude, just trying to point you in the
proper location, you really should post this type of message in the
programming newsgroup (...access.modulesdaovba).

Besides that, you want to use a routine like:

**********************
Function SendMessage(Dwg As String, Issue As String, Lead As String)
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([email protected])
'Check
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 = "Some Subject Line You Want To Appear"
.Body = "Actual Content of the E-mail"
'.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

End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Function
***************************

This should at least get you started! Hope it helps,

Daniel
 
Back
Top