MAPI/Outlook question

  • Thread starter Thread starter fniles
  • Start date Start date
F

fniles

Our VB program sends an email using MAPI.
If the program runs from a machine with Outlook 2000, the email was
sent without any prompt.
But, if the program runs from a machine with Outlook version later
than 2000 (like my machine has Outlook 2007), before the email is
sent, it prompt a message that say "A program is trying to send an e-
mail message on your behalf. If this is unexpected, click Deny and
verify your antivirus software is up-to-date. For more information
about e-mail safety and how you might be able to avoid getting this
warning, click Help." with buttons "Allo", "Deny" "Help".

I tested by going to my Outlook - Tools - Trust Center - Programmatic
Access and check "Never warn me about suspicious activity (not
recommended) ", but still get the prompt.
Is there anything I can do from my program that will not make the
prompt to show up ?

Thank you
 
fniles said:
Our VB program sends an email using MAPI.
If the program runs from a machine with Outlook 2000, the email was
sent without any prompt.
But, if the program runs from a machine with Outlook version later
than 2000 (like my machine has Outlook 2007), before the email is
sent, it prompt a message that say "A program is trying to send an e-
mail message on your behalf. If this is unexpected, click Deny and
verify your antivirus software is up-to-date. For more information
about e-mail safety and how you might be able to avoid getting this
warning, click Help." with buttons "Allo", "Deny" "Help".

I tested by going to my Outlook - Tools - Trust Center - Programmatic
Access and check "Never warn me about suspicious activity (not
recommended) ", but still get the prompt.
Is there anything I can do from my program that will not make the
prompt to show up ?

Few options:

1 - Use Outlook Redemption(Preferred):

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

2 - Use ClickYes software:

http://www.contextmagic.com/express-clickyes/
 
Our VB program sends an email using MAPI.
If the program runs from a machine with Outlook 2000, the email was
sent without any prompt.
But, if the program runs from a machine with Outlook version later
than 2000 (like my machine has Outlook 2007), before the email is
sent, it prompt a message that say "A program is trying to send an e-
mail message on your behalf. If this is unexpected, click Deny and
verify your antivirus software is up-to-date. For more information
about e-mail safety and how you might be able to avoid getting this
warning, click Help." with buttons "Allo", "Deny" "Help".

I'd suggest asking in an Outlook newsgroup/forum. I have a vague
memory of a comment from someone stating that, in newer versions of
Outlook, if your antivirus and other software is up to date, that you
wouldn't be getting this message. However, as far as I know, Outlook
2007 is one of those newer versions.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 
You''re posting to both the VB and the VB.Net group.
??

And didn't you ask about this awhile back? I though
you started out with Outlook, then there were several
discussions about less limited ways to send email.
(Ex.: 9/23 "How do you send an SMTP email with embedded
image ?")

Now you're back to using Outlook automation?

| Our VB program sends an email using MAPI.
| If the program runs from a machine with Outlook 2000, the email was
| sent without any prompt.
| But, if the program runs from a machine with Outlook version later
| than 2000 (like my machine has Outlook 2007), before the email is
| sent, it prompt a message that say "A program is trying to send an e-
| mail message on your behalf. If this is unexpected, click Deny and
| verify your antivirus software is up-to-date. For more information
| about e-mail safety and how you might be able to avoid getting this
| warning, click Help." with buttons "Allo", "Deny" "Help".
|
| I tested by going to my Outlook - Tools - Trust Center - Programmatic
| Access and check "Never warn me about suspicious activity (not
| recommended) ", but still get the prompt.
| Is there anything I can do from my program that will not make the
| prompt to show up ?
|
| Thank you
 
Thank you all for the replies.
This is a different project than the other posting that I posted.
The same problem happened on both VB6 and VB.NET program.
Unfortunately, we can only use MS objects, not 3rd party.
 
fniles said:
Our VB program sends an email using MAPI.
If the program runs from a machine with Outlook 2000, the email was
sent without any prompt.
But, if the program runs from a machine with Outlook version later
than 2000 (like my machine has Outlook 2007), before the email is
sent, it prompt a message that say "A program is trying to send an e-
mail message on your behalf. If this is unexpected, click Deny and
verify your antivirus software is up-to-date. For more information
about e-mail safety and how you might be able to avoid getting this
warning, click Help." with buttons "Allo", "Deny" "Help".

I tested by going to my Outlook - Tools - Trust Center - Programmatic
Access and check "Never warn me about suspicious activity (not
recommended) ", but still get the prompt.
Is there anything I can do from my program that will not make the
prompt to show up ?

That was a "feature" added to Outlook beginning, I think, with Outlook 2002.

That is one of the reasons why I personally don't use Outlook for sending
emails. These emails are sent from a Windows Service app that runs 24/7
importing items (sales orders, purchase orders, GL transaction items, etc.)
into ERP software. If errors occur during any of these, an email with an an
error log attached to it is sent to specific persons. That prompt from
Outlook was a major problem. I chose to use CDO, which utilizes an SMTP
server and bypasses MAPI completely. The only complaint some companies have
had is that there's no email in a Sent mailbox. But, that's kind of
ridiculous complaint because they can have the email sent to anyone in their
company they choose. So the email is just in their in box rather than their
sent box. Plus, the error log files are never deleted unless they do so
manually themselves, so they can just open the file if they ever need to.

The only other downside, if you can call it that, is that someone needs to
know and provide the SMTP server name and possibly logon credentials (I've
found that with most companies, if emails are sent only to others within the
company, credentials usually aren't necessary). Those get saved, encrypted,
so they only need entered once during configuration.

CDO is really pretty simple to use. And as I mentioned, you can attach files
to your emails. You can even use HTML to create the email body. There is no
dependency on Outlook or any other MAPI provider, which IMO is another big
plus.

As mentioned, if you really want to continue using Outlook for whatever
reason, Redemption is one solution. But that's yet another ActiveX component
you must distribute and install, adds additional overhead, and STILL has a
dependency on Outlook being installed. There's none of that with CDO as it's
part of Windows.
 
fniles said:
Thank you all for the replies.
This is a different project than the other posting that I posted.
The same problem happened on both VB6 and VB.NET program.
Unfortunately, we can only use MS objects, not 3rd party.

Then I even more strongly suggest that you consider using CDO. Here's the
function I use. You'll obviously need/want to make some changes to the
code. For example, you may not want to store the settings (smtp server name,
credentials, etc.) in an INI file as I have. You may want to store them in
a database or whatever. You may also not want to verify that a file for
attachment actually exists (if you do, you can just write your own
FileExists function).

The email body, recipient list, and file attachments (can be a string or any
array of strings) get passed to the function. You do not need to specify
any references in VB's References dialog box. The code uses late-binding
for the CDO objects. If you want to use early-binding, however, you could.
I've provided the CDO objects you'd use as comments in the variable
declarations. If you use early-binding, comment out the 2 cdo<x> constants
(the constants, NOT the variables).

This code also represents one of the very FEW times that I'll ever use a
Variant data type. For this function and purpose, it just makes sense though
because it allows for either a single string or an array to be passed for
the file(s) to be attached to the email. Also note that it's an optional
parameter.

-----BEGIN CODE
Public Function SendMailSMTP(ByVal EmailBody As String, ByVal sMailTo As
String, Optional varFileAttachment As Variant) As Boolean

Dim sErrMsg As String
Dim sMailFrom As String
Dim sSMTPServer As String
Dim sSubject As String
Dim sUser As String
Dim sPassword As String
Dim cdoConfig As Object 'CDO.Configuration
Dim cdoMessage As Object 'CDO.Message
Dim sBuffer As String
Dim lBuffer As Long
Dim Index As Long

Const SCHEMA As String =
"http://schemas.microsoft.com/cdo/configuration/"
Const cdoSendUsingPort As Long = 2
Const cdoBasic As Long = 1

On Error GoTo EH
lBuffer = 255

'Read email settings from INI file
If Len(Trim$(sMailTo)) = 0 Then
'Only read TO recipients if not passed in
sBuffer = String$(lBuffer, vbNullChar)
Call GetPrivateProfileString("Email", "To", "", sBuffer, lBuffer,
INIFile)
sMailTo = StripNulls(sBuffer)
End If

sBuffer = String$(lBuffer, vbNullChar)
Call GetPrivateProfileString("Email", "From", "Administrator", sBuffer,
lBuffer, INIFile)
sMailFrom = StripNulls(sBuffer)

sBuffer = String$(lBuffer, vbNullChar)
Call GetPrivateProfileString("Email", "SMTPServer", "", sBuffer,
lBuffer, INIFile)
sSMTPServer = StripNulls(sBuffer)

sBuffer = String$(lBuffer, vbNullChar)
GetPrivateProfileString "Email", "UserName", "", sBuffer, lBuffer,
INIFile
sUser = SimpleEncrypt(StripNulls(sBuffer), False)

sBuffer = String$(lBuffer, vbNullChar)
GetPrivateProfileString "Email", "Password", "", sBuffer, lBuffer,
INIFile
sPassword = SimpleEncrypt(StripNulls(sBuffer), False)

sBuffer = String$(lBuffer, vbNullChar)
Call GetPrivateProfileString("Email", "Subject", "SOP Import Error Log",
sBuffer, lBuffer, INIFile)
sSubject = StripNulls(sBuffer)

If (Len(sMailTo) > 0) And (Len(sMailFrom) > 0) And (Len(sSMTPServer) >
0) Then
Set cdoMessage = CreateObject("CDO.Message")

'Create CDO Configuration
Set cdoConfig = CreateObject("CDO.Configuration")

cdoConfig.Fields.Item(SCHEMA & "sendusing") = cdoSendUsingPort
cdoConfig.Fields.Item(SCHEMA & "smtpserver") = sSMTPServer

If Len(sUser) Then
cdoConfig.Fields.Item(SCHEMA & "smtpauthenticate") = cdoBasic
cdoConfig.Fields.Item(SCHEMA & "sendusername") = sUser
cdoConfig.Fields.Item(SCHEMA & "sendpassword") = sPassword
End If

cdoConfig.Fields.Update

With cdoMessage
Set .Configuration = cdoConfig
.To = sMailTo
.From = sMailFrom
.Subject = sSubject
.AutoGenerateTextBody = True
'.TextBody = EmailBody
.HTMLBody = Replace$(EmailBody, vbCrLf, "<BR>")

If Not IsMissing(varFileAttachment) Then
If IsArray(varFileAttachment) Then
For Index = LBound(varFileAttachment) To
UBound(varFileAttachment)
If FileExists(varFileAttachment(Index)) Then
.AddAttachment varFileAttachment(Index)
End If
Next
Else
If FileExists(varFileAttachment) Then
.AddAttachment varFileAttachment
End If
End If
End If

.Send
SendMailSMTP = True
End With
End If

Screen.MousePointer = vbDefault
Exit Function

EH:

Screen.MousePointer = vbDefault

sErrMsg = "The following error was raised in procedure SendMailSMTP." &
vbCrLf & vbCrLf
sErrMsg = sErrMsg & "Error Number: " & Err.Number & vbCrLf
sErrMsg = sErrMsg & "Source: " & Err.Source & vbCrLf
sErrMsg = sErrMsg & "Error Message: " & Err.Description

#If SERVICE = 1 Then
Forms(0).NTS.LogEvent svcEventError, svcMessageError,
"WEBORDER_IMPORT: " & sErrMsg
#Else
MsgBox sErrMsg, vbCritical, App.Title
#End If

SendMailSMTP = False

End Function
-----END CODE

Perhaps this one function can solve all your email problems that you've
lately been posting.
 
The only complaint some companies have
had is that there's no email in a Sent mailbox. But, that's kind of
ridiculous complaint because they can have the email sent to anyone in their
company they choose. So the email is just in their in box rather than their
sent box. Plus, the error log files are never deleted unless they do so
manually themselves, so they can just open the file if they ever need to.

I always log the emails sent in some fashion. If they aren't already
part of an error handling system which is already logged.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 
Tony Toews said:
I always log the emails sent in some fashion. If they aren't already
part of an error handling system which is already logged.

What do you mean?

What I'm getting at is that the purpose of the email is NOTHING more than
sending an error log file, which is saved on THEIR system and they have
access to. Why does there need to be a record (in the form of a sent email)
that an email of the error log was sent?

Or are you talking about something else?

I really don't know what you were getting at with your reply.
 
What do you mean?

What I'm getting at is that the purpose of the email is NOTHING more than
sending an error log file, which is saved on THEIR system and they have
access to. Why does there need to be a record (in the form of a sent email)
that an email of the error log was sent?

Or are you talking about something else?

I really don't know what you were getting at with your reply.

My sentence was not clear. I have two different situations in very
different types of applications.

1) As you are doing an email can be optionally sent if an error
occurs. I agree that no log is required.

2) I have a membership application for a club which does 95% of it's
renewals via email. I also send out email notices of meetings, URL
of newsletters and other items of general interest to the membershipo.
(Those few who don't have email addresses get a snail mail renewal
reminder and that's it.)

All those kinds of emails I log so that if there's ever any question I
can respond stating "I sent this email at this date/time to that email
address."

There have been several questions over the years from folks wondering
why they didn't get a renewal reminder. Turns out that they had
moved, changed email addresses and their old phone number no longer
worked. And a few other misc questions.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 
FNiles,

You say your problem is not special VB or VB Net related but in your idea
more the Mail API.
That one is the interface between Exchange Server (formally Mail Server) and
its clients.

In my idea more an Exchange Forum question than a VB question.
http://social.technet.microsoft.com/Forums/en-US/category/exchangeserver

If it is not handling with Exchange server and it has no attachments, I
would go for avoiding the MAPI and sending using the default Mail Client,
although that pops up the mailbox.
(If you don't know how to do that in the versions from VB than create a
separate new message for the Classic VB newsgroup and the VB Net
newsgroup/forums)

If the latter is unwanted and it is about non Exchange Server problem, than
there is also System.Net.Mail, however that has also many issues related to
the type of client.
For links to that also the previous mentioned places for VB Net.

In Net there are more solutions, but then first separate the directions of
your messages to VB classic or VB Net, it is currently so nice decent in the
first newsgroup.

Success with finding a solution.

Cor

"fniles" wrote in message

Our VB program sends an email using MAPI.
If the program runs from a machine with Outlook 2000, the email was
sent without any prompt.
But, if the program runs from a machine with Outlook version later
than 2000 (like my machine has Outlook 2007), before the email is
sent, it prompt a message that say "A program is trying to send an e-
mail message on your behalf. If this is unexpected, click Deny and
verify your antivirus software is up-to-date. For more information
about e-mail safety and how you might be able to avoid getting this
warning, click Help." with buttons "Allo", "Deny" "Help".

I tested by going to my Outlook - Tools - Trust Center - Programmatic
Access and check "Never warn me about suspicious activity (not
recommended) ", but still get the prompt.
Is there anything I can do from my program that will not make the
prompt to show up ?

Thank you
 
Back
Top