Annoying "virus" alert when using code to send mail

S

steve

I am getting an alert when using the below code to send mail from Excel.
How do I prevent this alert?

Thanks for your help...

The alert reads:
A program is trying to automatically send e-mail on your behalf.
Do you want to Allow this.
If this is unexpected, it may be a virus and you should choose "No".

Sub SendMyMail()
Dim subj As String
Application.DisplayAlerts = False

If MsgBox("Ready to send?", vbYesNo + vbQuestion) = vbYes Then
subj = Sheets(2).Cells(7, 3) & " Quote "
subj = subj & InputBox("Add to your Subject Line", "email Subject")
subj = WorksheetFunction.Proper(subj)
'(e-mail address removed)
'Emails the activeworkbook'
ActiveWorkbook.SendMail Recipients:="(e-mail address removed)", _
Subject:=subj, ReturnReceipt:=True
End If

Application.DisplayAlerts = True
End Sub
 
S

steve

Ron,

Thank you for your prompt response! You confirmed my worst fear -
having to disable the function in Outlook. Don't want to do that!

Your code specifies that the user must be connected to the internet. My
users are salesmen (on laptops) and they may or may not have internet
fired up. (I'll have to check this out to make sure.)

Tried the code in 97 & 2k and got an error on ".send"
(was on line) (Windows 2k)
Run Time Erro '-2147220960 (80040220)':
The "SendUsing" configuration value is invalid.

Both versions do not recognize "send".

Any suggestions?

Sub CDO_Send_Workbook()
' This sub use late binding, you don't have to set a reference' It is not
working in Windows 98 and ME.' You must be online when you run the sub
Dim iMsg As Object
Dim iConf As Object
Dim WB As Workbook
Dim WBname As String Application.ScreenUpdating = False
Set WB = ActiveWorkbook
'If you want to mail the workbook where the code is placed you must use
'Set WB = ThisWorkbook WBname = WB.Name & " " & Format(Now,
"dd-mm-yy h-mm-ss") & ".xls" WB.SaveCopyAs "C:/" & WBname
' It will save a copy of the file in C:/ with a Date and Time stamp
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.From = """Ron"" <[email protected]>"
.Subject = "This is a test"
.TextBody = "Hi there"
.AddAttachment "C:/" & WBname
'.AddAttachment "C:/Test.txt"
' You can add any file you want with .AddAttachment "C:/Test.txt"End With
Kill "C:/" & WBname 'If you not want to delete the file you send delete
this line
Set iMsg = Nothing
Set iConf = Nothing
Set WB = Nothing
Application.ScreenUpdating = True
End Sub
--
sb
Ron de Bruin said:
 
R

Ron de Bruin

Thank you for your prompt response! You confirmed my worst fear -
having to disable the function in Outlook. Don't want to do that!

Read good this you can only do in Outlook Express
See the links for Outlook

Outlook

Outlook Redemption
http://www.dimastr.com/redemption/

Express ClickYes
http://www.express-soft.com/mailmate/clickyes.html

If you want to use CDO see the problem section for a macro to fill in the Smtp server in the code


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




steve said:
Ron,

Thank you for your prompt response! You confirmed my worst fear -
having to disable the function in Outlook. Don't want to do that!

Your code specifies that the user must be connected to the internet. My
users are salesmen (on laptops) and they may or may not have internet
fired up. (I'll have to check this out to make sure.)

Tried the code in 97 & 2k and got an error on ".send"
(was on line) (Windows 2k)
Run Time Erro '-2147220960 (80040220)':
The "SendUsing" configuration value is invalid.

Both versions do not recognize "send".

Any suggestions?

Sub CDO_Send_Workbook()
' This sub use late binding, you don't have to set a reference' It is not
working in Windows 98 and ME.' You must be online when you run the sub
Dim iMsg As Object
Dim iConf As Object
Dim WB As Workbook
Dim WBname As String Application.ScreenUpdating = False
Set WB = ActiveWorkbook
'If you want to mail the workbook where the code is placed you must use
'Set WB = ThisWorkbook WBname = WB.Name & " " & Format(Now,
"dd-mm-yy h-mm-ss") & ".xls" WB.SaveCopyAs "C:/" & WBname
' It will save a copy of the file in C:/ with a Date and Time stamp
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.From = """Ron"" <[email protected]>"
.Subject = "This is a test"
.TextBody = "Hi there"
.AddAttachment "C:/" & WBname
'.AddAttachment "C:/Test.txt"
' You can add any file you want with .AddAttachment "C:/Test.txt"End With
Kill "C:/" & WBname 'If you not want to delete the file you send delete
this line
Set iMsg = Nothing
Set iConf = Nothing
Set WB = Nothing
Application.ScreenUpdating = True
End Sub
 
S

steve

Ron,

Thanks, again! But now the problem is having my users download and
install something - that won't work (unfortunately).

Guess I'll just have them click the "Yes" button...
 
M

Michael D. Ober

Outlook Express is part of Internet Explorer. If they have IE 5.0 or later,
then they already have a relatively current (and stable) version of Outlook
Express.

Mike.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top