Automated E-mail

G

Guest

Hello,

I'm using the following code (provided by a previous post) to send an
automated e-mail:

********************
Function SendMessage(Dwg As String, Issue As String, Lead As String)
On Error GoTo Err_Func:

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("Any Guy") 'Check

' 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 = "Drawing " & Dwg & " " & Issue & " Review Notification"
.Body = Lead & " has just signed off on drawing " & Dwg & " " & Issue
& "." & vbCrLf & "Please take the appropriate steps to perform your
departmental review of the drawing and enter your signature and approval date
in the database once completed"
'.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

Exit_Func:
Exit Function

Err_Func:
If Err.Number = 287 Then 'Triggered by the user cancelling the
e-mail send action
Else
MsgBox "MS Access has generated the following error" & vbCrLf &
vbCrLf & "Error Number: " & Err.Number & vbCrLf & "Error Description: "
& Err.Description, vbCritical, "An Error has Occured!" '*** explain the
error that occured and exit the sub
End If
Resume Exit_Func

End Function
*******************

When the code is run it always opens a form where the user has to authorize
the use of his outlook account to send the message (they have to authorize it
3 times). Is there a way around this without having to resort to third party
software? This is an internal software sending e-mail internally only!

Thanks,

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top