?
Solved

Sending e-mail through an MSAccess Form

Posted on 2003-02-27
16
Medium Priority
?
319 Views
Last Modified: 2007-12-19
I have some code that will send e-mail through MSOutlook at the click of a command button.  The code works fine.  I have just one annoyance I cannot figure out:

After I click the cmdButton and the code sends the instructions to MSOutlook, an Outlook MsgBox appears and it 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' <YES> <NO> <HELP>"

How do I stop this popup?

Thanks
0
Comment
Question by:Dale Massicotte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +2
16 Comments
 
LVL 1

Expert Comment

by:AceDefabul
ID: 8038087
This is cused by an Outlook email security update.  Your
best bet for complete info is Support.Microsoft.com
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 200 total points
ID: 8038189
Depends - are you using Exchange ? If so, there is a reasonably easy way to work round it. If not, you will have to obtain the unsecure CDO libraries and install them.

Have a look here:
http://www.granite.ab.ca/access/email.htm

Scroll down to the "Outlook Security Patch in Outlook 98, 2000 SP-2 and Outlook 2002" box. That should give you some more information.
0
 
LVL 1

Expert Comment

by:matey18
ID: 8038596
In Outlook Express, go to Tools > Options > Security tab

Look at the options, and uncheck the box that says:

Warn Me When Other Applications Try To Send Mail As Me

That way the message should not appear
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:Alan Warren
ID: 8039386
' References cdosys.dll - Microsoft CDO for Windows 2000 Library
  Call SendCDOSys(sFromAddress, sToAddress, sSubject, sBodyText, sSMTPServer)


Public Sub SendCDOSys( _
  ByVal FromAddress As String, _
  ByVal ToAddress As String, _
  Optional ByVal Subject As String = "", _
  Optional ByVal TextBody As String = "", _
  Optional ByVal SMTPServer As String = "" _
)
 
  Dim oConfiguration As CDO.Configuration
  Dim oMessage As CDO.Message
 
  Set oConfiguration = New CDO.Configuration
  With oConfiguration.Fields
    .Item(cdoSMTPAuthenticate) = cdoAnonymous
    If Trim(SMTPServer) = "" Then
      .Item(cdoSendUsingMethod) = cdoSendUsingPickup
    Else
      .Item(cdoSendUsingMethod) = cdoSendUsingPort
      .Item(cdoSMTPServer) = SMTPServer
    End If
    ' iw: may need this in future, not researched
    '"SMTPLogonAccountName"   String. Read/write.
    '   The account name to use if your SMTP server requires you to log on.
    '"SMTPLogonPassword"      String. Write-only.
    '   The user password for the SMTP account. In order to protect passwords
    '   from detection, this field can be set but not retrieved.
    .Update
  End With
 
  ' create new message, add: from, to, subject and textbody
  Set oMessage = New CDO.Message
  With oMessage
    Set .Configuration = oConfiguration
    .From = FromAddress
    .To = ToAddress
    .Subject = Subject
    .TextBody = TextBody
    ' iw: Importance doesn't work
    ' .Fields(CDO.cdoImportance) = CDO.cdoHigh    'cdoNormal, cdoHigh, cdoLow
    .Send
  End With

ExitProcedure:
  On Error Resume Next
  Set oMessage = Nothing
  Set oConfiguration = Nothing
  Exit Sub
End Sub


0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 8039414
' References cdosys.dll - Microsoft CDO for Windows 2000 Library
  Call SendCDOSys(sFromAddress, sToAddress, sSubject, sBodyText, sSMTPServer)


Public Sub SendCDOSys( _
  ByVal FromAddress As String, _
  ByVal ToAddress As String, _
  Optional ByVal Subject As String = "", _
  Optional ByVal TextBody As String = "", _
  Optional ByVal SMTPServer As String = "" _
)
 
  Dim oConfiguration As CDO.Configuration
  Dim oMessage As CDO.Message
 
  Set oConfiguration = New CDO.Configuration
  With oConfiguration.Fields
    .Item(cdoSMTPAuthenticate) = cdoAnonymous
    If Trim(SMTPServer) = "" Then
      .Item(cdoSendUsingMethod) = cdoSendUsingPickup
    Else
      .Item(cdoSendUsingMethod) = cdoSendUsingPort
      .Item(cdoSMTPServer) = SMTPServer
    End If
    ' iw: may need this in future, not researched
    '"SMTPLogonAccountName"   String. Read/write.
    '   The account name to use if your SMTP server requires you to log on.
    '"SMTPLogonPassword"      String. Write-only.
    '   The user password for the SMTP account. In order to protect passwords
    '   from detection, this field can be set but not retrieved.
    .Update
  End With
 
  ' create new message, add: from, to, subject and textbody
  Set oMessage = New CDO.Message
  With oMessage
    Set .Configuration = oConfiguration
    .From = FromAddress
    .To = ToAddress
    .Subject = Subject
    .TextBody = TextBody
    ' iw: Importance doesn't work
    ' .Fields(CDO.cdoImportance) = CDO.cdoHigh    'cdoNormal, cdoHigh, cdoLow
    .Send
  End With

ExitProcedure:
  On Error Resume Next
  Set oMessage = Nothing
  Set oConfiguration = Nothing
  Exit Sub
End Sub


0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 8039438
' References cdosys.dll - Microsoft CDO for Windows 2000 Library
  Call SendCDOSys(sFromAddress, sToAddress, sSubject, sBodyText, sSMTPServer)


Public Sub SendCDOSys( _
  ByVal FromAddress As String, _
  ByVal ToAddress As String, _
  Optional ByVal Subject As String = "", _
  Optional ByVal TextBody As String = "", _
  Optional ByVal SMTPServer As String = "" _
)
 
  Dim oConfiguration As CDO.Configuration
  Dim oMessage As CDO.Message
 
  Set oConfiguration = New CDO.Configuration
  With oConfiguration.Fields
    .Item(cdoSMTPAuthenticate) = cdoAnonymous
    If Trim(SMTPServer) = "" Then
      .Item(cdoSendUsingMethod) = cdoSendUsingPickup
    Else
      .Item(cdoSendUsingMethod) = cdoSendUsingPort
      .Item(cdoSMTPServer) = SMTPServer
    End If
    ' iw: may need this in future, not researched
    '"SMTPLogonAccountName"   String. Read/write.
    '   The account name to use if your SMTP server requires you to log on.
    '"SMTPLogonPassword"      String. Write-only.
    '   The user password for the SMTP account. In order to protect passwords
    '   from detection, this field can be set but not retrieved.
    .Update
  End With
 
  ' create new message, add: from, to, subject and textbody
  Set oMessage = New CDO.Message
  With oMessage
    Set .Configuration = oConfiguration
    .From = FromAddress
    .To = ToAddress
    .Subject = Subject
    .TextBody = TextBody
    ' iw: Importance doesn't work
    ' .Fields(CDO.cdoImportance) = CDO.cdoHigh    'cdoNormal, cdoHigh, cdoLow
    .Send
  End With

ExitProcedure:
  On Error Resume Next
  Set oMessage = Nothing
  Set oConfiguration = Nothing
  Exit Sub
End Sub


0
 

Author Comment

by:Dale Massicotte
ID: 8042679
Alan - one posting of the code would have been okay,  lol.  What is its purpose anyway?  Does it work on both WIN2000 and XP platforms??

BTW - I there are 5 computers on a network running Office 2000 which includes Access 2000 and Outlook 2000.

Isn't their just a quick and simple fix here?  Why so complicated?

My code is simple.  It is as follows:

Dim olapp As Object
Dim oitem As Object
Set olapp = CreateObject("Outlook.Application")
Set oitem = olapp.CreateItem(0)
oitem.Subject = [Message]
oitem.To = "emailaddress@msg.myvzw.com"
oitem.Body = [Message]
oitem.Send

Let's go experts...we got 100 points on the line.  I know cash is king, but points are bragging rights!
0
 

Author Comment

by:Dale Massicotte
ID: 8042699
Alan - one posting of the code would have been okay,  lol.  What is its purpose anyway?  Does it work on both WIN2000 and XP platforms??

BTW - I there are 5 computers on a network running Office 2000 which includes Access 2000 and Outlook 2000.

Isn't their just a quick and simple fix here?  Why so complicated?

My code is simple.  It is as follows:

Dim olapp As Object
Dim oitem As Object
Set olapp = CreateObject("Outlook.Application")
Set oitem = olapp.CreateItem(0)
oitem.Subject = [Message]
oitem.To = "emailaddress@msg.myvzw.com"
oitem.Body = [Message]
oitem.Send

Let's go experts...we got 100 points on the line.  I know cash is king, but points are bragging rights!
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8042700
DalerTheWhaler,

Unfortunately it isn't a quick and easy fix - nothing ever is in the MS world. If you follow the link I posted, the possible fixes are there (the Exchange fix is easy enough to implement if it applies to you).
0
 

Author Comment

by:Dale Massicotte
ID: 8042976
I do not believe that my computer has Exchange, and I will follow the link and hopefully my answer will be there.

You guys are the best!
0
 

Author Comment

by:Dale Massicotte
ID: 8044907
What is an unsecure CDO library?   BTW I am close to solving the problem and awarding the points to shanesuebsaharn
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8045031
The unsecure CDO library is called (I think) cdo.dll. The unsecure version is version 1.21, and doesn't contain the "security" features that MS so kindly built in for us. You can obtain it here if you need it:
http://ourworld.compuserve.com/homepages/attac-cg/

Go to "Freeware File & Code", and the bottom item is the unsecure CDO library.
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 8045259
I wish they would fix the refresh bug that causes double posting. Chech out the times of the postings, they are 5 minutes apart. I post, I go on with my work, 5 minutes later, I refresh. I get another posting. If they invoked a reset after posting, this problem would be solved. I'm really glad my e-bank doesn't resubmit transactions when I refresh.

 DalerTheWhaler

Microsoft are only going to tighten the security on outlook in the future, dont fight it. I used to use the Outlook object for sending mail from access, not any more. That is why they developed CDO, it is wrapper for MAPI, they are trying to make it user friendly.

Use your smtp server that came with win2000. You can set smtpserver = "localhost"

If you didnt install the smtp server:

Set it to the same setting that outlook requires to set up an account.
Tools > Accounts > Properties > Servers > Outgoing mail [SMTP] "Mail.MyISP.com"
Your isp will allow mail forwarding.
'References cdosys.dll - Microsoft CDO for Windows 2000 Library

Call SendCDOSys("DalerTheWhaler@somewhere.com", "alan@cashoz.com", "test CDO", "Hope this gets there", "Mail.MyISP.com")

When you get that sorted out, have a look at htmlformat, you can send mail that looks like web pages with buttons and dropdowns and go berserk here...

Hope to hear from you soon.

Regards Alan
Sorry about the multiple posts, definately not intentional.




0
 
LVL 1

Expert Comment

by:matey18
ID: 8053442
I posted this earlier, but not sure if you tried it...that same box appears due to the below box being ticked, so try unticking it:

In Outlook Express, go to Tools > Options > Security tab

Look at the options, and uncheck the box that says:

Warn Me When Other Applications Try To Send Mail As Me

That way the message should not appear
0
 

Author Comment

by:Dale Massicotte
ID: 8057664
Option is not avail with Outlook 2000.  And it is caused by the recent security updates
0
 

Author Comment

by:Dale Massicotte
ID: 8058771
Here is what I came up with:

Using a list box [CourierID] I select the mail recipients (1 or more) to send my message from my text box [Message].  Since Outlook 2000 has to be open for it to work the code instructs the user to open outlook if they try to execute the code without it being open.

I have a reference pointing to "SafeOutlook Librabry" and the DLL can be downloaded for free at http://www.dimastr.com/Redemption/
there is no permission to distibute your application with the free download.

It works awesome.  Points awarded to Shanesue... for pointing me in the right direction.

Here's the code:

Dim BA As String
Dim ctlList As Control, varItem As Variant
Dim Outlook As Outlook.Application
Set Outlook = CreateObject("Outlook.Application")

' Check to see if MSOutlook is open
'Try to open Outlook
On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Err = 0 Then 'Outlook is open
    Dim Application As Object
    Set Application = CreateObject("Outlook.Application")
    Set Namespace = Application.GetNamespace("MAPI")
    Namespace.Logon

    Dim SafeItem, oitem
    Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
    Set oitem = Application.createItem(0) 'Create a new message
    SafeItem.Item = oitem 'set Item property
   
    ' Return Control object variable pointing to list box.
    Set ctlList = Forms!frmtxtmsg!CourierID
    ' Enumerate through selected items.
   
    For Each varItem In ctlList.ItemsSelected
        ' Print value of bound column.
        CACA = ctlList.ItemData(varItem)
        BABA = DLookup("[mobilemail]", "[Query2]", "[Driver No] = Forms![frmtxtmsg]![caca]")
        SafeItem.Recipients.Add [BABA]
    Next varItem

    SafeItem.Recipients.ResolveAll
    SafeItem.Subject = "Premier"
    SafeItem.Body = [Message]
    SafeItem.Send
    Set Btn = Application.ActiveExplorer.CommandBars.FindControl(1, 5488)
    Btn.Execute
Else
BA = MsgBox("Before sending a text message, you must first start Microsoft Outlook", vbExclamation, "ATTENTION!")
End If
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question