Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select profile window after the docmd.sendobject 1

Status
Not open for further replies.

ElGuapo

Programmer
Aug 29, 2001
42
0
0
SI
I have written a module that sends emails that are generated from a database once a week.

The proggie runs on a locked workstation. When I use the sendobject command it prompts me to choose the profile in MS Outlook (97). This prompt window stops the execution of the module. I have solved this by using the sendkeys function that works fine if the workstation is not locked. However if I lock the workstation the sendkeys does not work.

Does anybody know another way to disable the select profile window when sending from Access 97.

10x

ElGuapo
 
I found that I had to use Outlook automation to get around the "Choose Profile" dialog. Here's some sample code I cut from one of my routines that you can adapt and try. This requires that you have the Outlook Library as a reference in your DB. The library for Access 97 is MSOLB8.OLB, and for Access 2000 is MSOLB9.OLB.
Code:
Private Sub SendMail(sMailTo As String, sSubject As String, sBody As String)
  Dim objOutlook   As New Outlook.Application
  Dim objNamespace As Outlook.NameSpace
  Dim objFolder    As Outlook.MAPIFolder
  Dim objItem      As Outlook.MailItem
  
  On Error GoTo SendMail_Err
  'Use Outlook automation to send e-mail, avoid "Choose Profile" dialog
  Set objNamespace = objOutlook.GetNamespace("MAPI")
  objNamespace.Logon "Microsoft Outlook", "", False, True  'Select Profile here
  Set objFolder = objNamespace.GetDefaultFolder(olFolderOutbox) 'Outbox
  Set objItem = objFolder.Items.Add(olMailItem)
  With objItem
    With .Recipients.Add(strMailTo) 'E-mail address must exist in
      .Type = olTo                  ' Outlook Address Book
      If Not .Resolve Then
        MsgBox "Cannot resolve address '" & sMailTo & "'", vbExclamation
        Exit Sub
      End If
    End With
    'Send attachment if needed
    'With .Attachments.Add("C:\TEMP\Test.doc")
      '.DisplayName = "Test Document"
    'End With
     .Subject = sSubject
     .Body = strBody
     .Importance = olImportanceHigh
     .Send
  End With

SendMail_Exit:
  On Error Resume Next
  objOutlook.Logoff
  Set objItem = Nothing
  Set objFolder = Nothing
  Set objNamespace = Nothing
  Set objOutlook = Nothing
  Exit Sub
  
SendMail_Err:
  MsgBox "Error #" & Err.Number & vbCrLf & Err.Description, vbOKOnly, "SendMail"
  Resume SendMail_Exit
End Sub
 
Set your default profile on the machine in the Mail and Fax icon in Control Panel. Then the machine will default automatically and that box won't pop up at all.

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top