Hi,
We are having the occassional error as per the subject line when the following code runs...
Now this code has run fine for years and not changed at all, but now on occassion it is erroring.
I've done the 'Google is my friend' and every thread I can find implies it is because the user clicks 'No' when the security warning comes up.
Well that can't be possible, we have a program installed called 'Express Click Yes', which automatically clicks 'Yes' , the user cannot click 'No' and the program only ever clicks 'Yes'.
Therefore what on earth is causing the error and making the function behave as if 'No' has been clicked, which isn't the case?
Your advice is appreciated.
Cheers,
1DMF.
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Google Rank Extractor -> Perl beta with FusionCharts
We are having the occassional error as per the subject line when the following code runs...
Code:
Function SendEmail(ByVal sTo As String, ByVal sSubject As String, ByVal sBody As String, Optional sFile As String, Optional sBlind As String)
On Error GoTo EH_SendEmail
Dim oApp As Outlook.Application
Dim sEmail As String
Dim iPos As Integer
Dim i As Integer
Dim iCount As Integer
Dim oMailItem As Outlook.MailItem
Dim oReceipt As Outlook.Recipient
Dim oAttach As Outlook.Attachment '- use to attach a file
Dim vEmail As Variant
SendEmail = True
'open Outlook
Set oApp = CreateObject("Outlook.Application")
'Create mail message
Set oMailItem = oApp.CreateItem(olMailItem)
'set email recipient
vEmail = Split(sTo, ";")
With oMailItem
For i = 0 To UBound(vEmail)
Set oReceipt = .Recipients.Add(vEmail(i))
oReceipt.Type = olTo
Next i
.Subject = sSubject
' .Body = sBody ' changed to be HTML email
.HTMLBody = sBody
'if Blind Copy needed
If Not IsNull(sBlind) And sBlind <> "" Then
.BCC = sBlind
End If
'use to attach a file at sFile
If Not IsNull(sFile) And sFile <> "" Then
Set oAttach = .Attachments.Add(sFile)
End If
'send to outlook outbox
.Send
End With
Set oReceipt = Nothing
Set oAttach = Nothing
Set oMailItem = Nothing
Set oApp = Nothing
Exit_SendEmail:
Exit Function
EH_SendEmail:
MsgBox "Error in EH_SendEmail " & Error(Err) & " " & CStr(Err) & vbCrLf & "Recipient = " & sTo & vbCrLf & "Subject = " & sSubject & vbCrLf & "Content = " & sBody
SendEmail = False
Resume Exit_SendEmail
End Function
Now this code has run fine for years and not changed at all, but now on occassion it is erroring.
I've done the 'Google is my friend' and every thread I can find implies it is because the user clicks 'No' when the security warning comes up.
Well that can't be possible, we have a program installed called 'Express Click Yes', which automatically clicks 'Yes' , the user cannot click 'No' and the program only ever clicks 'Yes'.
Therefore what on earth is causing the error and making the function behave as if 'No' has been clicked, which isn't the case?
Your advice is appreciated.
Cheers,
1DMF.
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Google Rank Extractor -> Perl beta with FusionCharts