|
Private Sub cmdEmailLetter_Click()
Dim result As Integer Dim displaymessage As Boolean Dim strSql As String Dim rsEmailAdd As Recordset Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment
strSql = "SELECT ProvEmail,SupEmail,LOEmail FROM Providers " & _ "WHERE ProvCode = " & Val(mid(Trim(Me.cmbProviders.Text), 1, 4)) Set rsEmailAdd = dbAtlas.OpenRecordset(strSql, dbOpenDynaset)
displaymessage = True ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg ' Add the To recipient(s) to the message. If rsEmailAdd.Fields("ProvEmail") <> "" Then Set objOutlookRecip = .Recipients.Add(rsEmailAdd.Fields("ProvEmail")) Else Set objOutlookRecip = .Recipients.Add(rsEmailAdd.Fields("SupEmail")) End If objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message. .Subject = "RE: " & (mid(Trim(Me.cmbSubject.Text), 3, 30)) & " IA Program" ' .Body = "This is a testing email from Atlas Software to see if we can automate sending the attachement files." & vbCrLf & vbCrLf .Importance = olImportanceHigh 'High importance
' Add attachments to the message. 'If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(sOutput) 'End If
' Resolve each Recipient's name. For Each objOutlookRecip In .Recipients objOutlookRecip.Resolve Next
' Should we display the message before sending? If displaymessage Then .Display Else ' .Save .sEnd End If End With objOutlook.Quit Set objOutlookMsg = Nothing Set objOutlookRecip = Nothing Set objOutlookAttach = Nothing Set objOutlook = Nothing fraDetails.Visible = True fraData.Visible = False txtSklInformMethod.Visible = False txtCorrespondenceDate.Visible = False Label6.Visible = False Label7.Visible = False txtSklInformMethod.Text = "Emailed Letter" txtCorrespondenceDate.Text = Date End Sub
|