Hi I have two functiions,
Cheque() whic simple check the reorcd in the table , whic reports need to sent email,
The 2nd function GenerateEmail() which giving me the error. "Method or Data Member not found.
I though the reference library missing but I already added the following library i.e.
-MS Outlook 12.0 Object Libray
-MS Office 12.0 Object Libaray
-others
The 2nd Function where the error come(red fonts) is as follows:
Please help me have I still miss any object or method?
Many thanks
Farhan
Cheque() whic simple check the reorcd in the table , whic reports need to sent email,
The 2nd function GenerateEmail() which giving me the error. "Method or Data Member not found.
I though the reference library missing but I already added the following library i.e.
-MS Outlook 12.0 Object Libray
-MS Office 12.0 Object Libaray
-others
The 2nd Function where the error come(red fonts) is as follows:
Please help me have I still miss any object or method?
Code:
Function GenerateEmail(sTo As String, sCC As String, sSubject As String, sBodyText As String, Optional sAttachment As String = "") As Boolean
Dim NewMessage As Outlook.MailItem
Dim objOutlook As New Outlook.Application
Dim objNamespace As Outlook.Namespace
On Error GoTo Err_Handler
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set NewMessage = Application.[COLOR=red]CreateItem([/COLOR]olMailItem)
With NewMessage
.SentOnBehalfOfName = "Information2, BNHFT"
.To = sTo
.CC = sCC
.Subject = sSubject
.BodyFormat = olFormatHTML
.Body = sBodyText
If sAttachment <> "" Then
.Attachments.Add Source:=sAttachment
End If
.DeleteAfterSubmit = True
.Send
DoEvents
End With
Set NewMessage = Nothing
GenerateEmail = True
Exit Function
Err_Handler:
MsgBox "Error: " & Err.Number & " - " & Err.Description, vbOKOnly, "ERROR!"
NewMessage.Close olDiscard
GenerateEmail = False
End Function
Many thanks
Farhan