brettdj
01-05-2006, 03:49 PM
Thread split from http://www.vbaexpress.com/forum/showthread.php?t=6587
Thanks guys, nice coding Killian and I like your sneekiness John.
The email code (courtesy Ron de Bruin) is an absolute riot, as (1) the user doesn't see the email leave his/her system - as far as I am aware, (2) you can send the email from anyone
I was wondering though if there was a better way to detect an unprotected sheet than running a Workbook event
Sub Mail_Small_Text_CDO()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
' Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
On Error Resume Next
strbody = "Some knob " & Environ("usernAme") & "has unprotected a worksheet"
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "My server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "David.Brett@XXX.com"
.CC = "Rod.Mainland@XXX.com"
.BCC = ""
.From = "SmurfLover@PVR.com"
.Subject = "Some knob has tried cracking the protection"
.TextBody = strbody
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
End Sub
Thanks guys, nice coding Killian and I like your sneekiness John.
The email code (courtesy Ron de Bruin) is an absolute riot, as (1) the user doesn't see the email leave his/her system - as far as I am aware, (2) you can send the email from anyone
I was wondering though if there was a better way to detect an unprotected sheet than running a Workbook event
Sub Mail_Small_Text_CDO()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
' Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
On Error Resume Next
strbody = "Some knob " & Environ("usernAme") & "has unprotected a worksheet"
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "My server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "David.Brett@XXX.com"
.CC = "Rod.Mainland@XXX.com"
.BCC = ""
.From = "SmurfLover@PVR.com"
.Subject = "Some knob has tried cracking the protection"
.TextBody = strbody
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
End Sub