Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
'Set the recipient for the new email
If infoReqMod.ReqInfoData.RptOpt = 1 Then
.To = "[email protected]"
ElseIf infoReqMod.ReqInfoData.RptOpt = 2 Then
.To = "DL KNA SSC A/P METRICS AND TECHNOLOGY"
ElseIf infoReqMod.ReqInfoData.RptOpt = 3 Then
.To = "[email protected]"
End If
'Set the recipient for a copy
.CC = "[email protected]"
'Set the subject
.Subject = "Information Request"
'The content of the document is used as the body for the email
.Body = infoReqMod.CreateBody
If infoReqMod.attachments.blnHaveAttach = True Then
Dim i As Integer
For i = 0 To infoReqMod.attachments.intCnt - 1
.attachments.Add infoReqMod.attachments.strAttach(i)
Next
End If
.Send
End With
If bStarted Then
'If we started Outlook from code, then close it
oOutlookApp.Quit
End If
|