?
Solved

Don't want SendObject to brings Choose Profile Dialog box

Posted on 2003-03-14
14
Medium Priority
?
719 Views
Last Modified: 2008-02-07
I'm using SendObject to send e-mail but it always brings up a dialog box titled "Choose Profile" that has a pulldown with my e-mail name in it.  The other thing in this pulldown is "Microsoft Exchange".  It has an options that says "Set as Default profile".  I checked this option but next time I test my SendObject, this dialog is displayed again.  I'm working on nightly maintenance VBA routine that attempts to send notification e-mail (i. e., Your document needs to be reviewed, etc.) to my users.  This is an unattended operations so I don't want it to display this dialog and stop running until I come in the next day.  Here is my code:

  DoCmd.SendObject acSendForm, strForm, acFormatHTML, strName, , , strSubject, strMessage, False

Is there any fix to prevent this dialog from coming up.  At a minimum, I need this fix to work on my PC.  Ideally, this fix could easily be put on all my user's PC as I use SendObject to send e-mail based on User input also.
0
Comment
Question by:schmir1
[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
  • 8
  • 6
14 Comments
 
LVL 9

Expert Comment

by:rherguth
ID: 8139363
I'll assume you checked the "Always use this profile" checkbox and it still prompts you.

If you have Outlook, you could also just instance Outlook using the current user profile:
Dim oOutlookApp, oInbox, oMail
Set oOutlookApp = new ActiveXObject("Outlook.Application").GetNameSpace("MAPI")
Set oInbox = oOutlookApp.GetDefaultFolder(olFolderInbox)
Set oMail = oInbox.Items.Add(olMailItem)
oMail.To = "<%=rsProject("PEMail")%>;"
oMail.CC = "<%=rsProject("BCMail")%>;"
oMail.Subject = "<%=sDisplayName%> - " + sProjectName + " Resource Authorization"
'oMail.Body = "" '  OR, for HTML Mail:
oMail.HTMLBody = "<B>" + sProjectName + "</B><BR>After careful review of project requirements, ..."
oMail.Display()          ' Or Mail.Send

Or you can use the Microsoft CDO objects.  They are installed with Office starting with Office 2000 and also installed with Windows 2000 and later Windows OSs.  The reference you're looking for is Microsoft CDO 1.21 Library or something similar.  

Public Function sendmail(Message As String)

  Dim osession As MAPI.Session
  Dim omessage As Message
  Dim oRecip As Recipient
  Dim oAttach As Attachment
 
  'Create session and logon
  Set osession = CreateObject("MAPI.Session")
  osession.Logon ("MS Exchange Settings")
  'you profile name may differ - you can also specify a logon and pw here
  Set omessage = osession.Outbox.Messages.Add
 
  'add recipients
  Set oRecip = omessage.Recipients.Add("recip1@HotMail.com", Type:=1)
  oRecip.Resolve
  Set oRecip = omessage.Recipients.Add("recip2@hishost.net", Type:=1)
  oRecip.Resolve
  Set oRecip = omessage.Recipients.Add("recip3@herhost.com", Type:=1)
  oRecip.Resolve
  'Note: Type:=1 For To: recipients
  '         Type:=2 For Cc: recipients
  '         Type:=3 For Bcc: recipients
 
 
  'Add attachments
  With omessage
       .Text = Message
       .subject = "Night Batch Failure"
       Set oAttach = .Attachments.Add
       With oAttach
           .Position = 2000
           .Name = "MyAttachment.txt" ' Name that appears in e-mail
           .Type = CdoFileData
           .ReadFromFile "C:\ComCareExport_051001.txt" ' Actual path to file
           .Source = "c:\ComCareExport_051001.txt" 'Actual path
       End With
       .Update
   End With
 
   'Send the Mail
   omessage.Send , showdialog:=False
   osession.DeliverNow
   osession.Logoff

End Function
0
 
LVL 9

Expert Comment

by:rherguth
ID: 8139382
Sorry, about the hastily converted javascript function above.  The new ActiveXObject() code should be the VB equivalent of CreateObject() and the weird <%=%> stuff is ASP server side code.  Just ignore it.  The second CDO function was copied from: http://www.experts-exchange.com/Databases/MS_Access/Q_20243072.html
0
 
LVL 9

Expert Comment

by:rherguth
ID: 8139393
Oh yes, and I left out one constant above for the Outlook code:
Dim olFolderInbox : olFolderInbox = 6
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:schmir1
ID: 8139456
It sounds like your proposing something other then the SendObject function.  I've got this function working in many areas of my DB and they have been fully tested.  I hate to have to redo everything just to get rid of the dialog box.  
0
 
LVL 9

Expert Comment

by:rherguth
ID: 8140878
Ah, I see.  So there is something different about this instance than the others?
0
 

Author Comment

by:schmir1
ID: 8144062
Yes the other e-mails are sent when users make inputs while they are stilling in front of their PCs and my new e-mail routine will send e-mail at night with no one to hit the OK button.
0
 
LVL 9

Expert Comment

by:rherguth
ID: 8144372
Another option would be to do a sendkey to OK the dialog in their absence.  You can even select a profile if necessary.  This may require implementing a few API calls to make sure the window is there and that it's active  Then send the keys to it.

I suspect you're better off changing your mail routine over to CDO.  CDO works with any MAPI mail client.
0
 

Author Comment

by:schmir1
ID: 8161740
I should never have used the SendObject.  It worked so well to start with.

Anyhow, I'm exploring getting Office 2000 SP3 and hoping that will fix it.

I believe it is a bug because even when I deleted one of the profiles, the dialog still comes up.  It has a check box that says "Use as default" but it always comes up again if you close and start up the database again.

Microsoft has a similar issue listed for OL2002.

http://support.microsoft.com/default.aspx?scid=kb;en-us;811472
0
 
LVL 9

Expert Comment

by:rherguth
ID: 8164762
That's why I suggested using some alternate mechanism.  I came across several complaints about the dialog while searching the web, but the only answer given, if any, was to switch to one of the other methods.  Sorry it didn't work out.  The other feature of CDO mail is that it's as easy to send HTML mail as Text mail.  The Outlook method I listed above is really not the best.  If you're going to rewrite it, use CDO and put it in a Module so that all your code refers to the one function.

I have found good code samples on this site in the past:
http://www.cdolive.com
0
 

Author Comment

by:schmir1
ID: 8389217
I found that my PC has this Profile dialog problem but another user's PC does not.  I'm hoping to get my IT people to fix my PC.  Is there any way to get this question transfered to the Outlook or e-mail area or just delete it.  Thanks everyone for trying to help.
0
 
LVL 9

Expert Comment

by:rherguth
ID: 8399168
If you're using Windows 2000 or Windows XP, you might just try deleting your profile (after backing it up) and letting windows recreate it.  Then copy the parts of your profile you want to keep like Favorites and outlook PSTs and such.
0
 

Author Comment

by:schmir1
ID: 8412648
Sounds worth a try.  Do you know which file it is?
0
 
LVL 9

Accepted Solution

by:
rherguth earned 2000 total points
ID: 8417392
It would be an entire directory structure under C:\Documents and Settings\<profile name> where the profile name is your Windows login.

Actually, I think that you could just rename the <profile name> directory to something else.  You must log in to Windows using a different login than the one you're renaming (ex. Administrator), rename the profile directory and then the next time you log in with your account, Windows will recreate your profile.  This means you lose most/all of your personalized Windows and Office settings, however, they are still around under the renamed profile.  If you want to recover them, just copy over what you need (PSTs and Favorites, etc), or reverse the process to get it all back.

Profiles are managed using the "User Profiles" tab of System Properties (right-click My Computer on the desktop and select Properties).

Just don't delete any profiles without backing them up or copying them.
0
 

Author Comment

by:schmir1
ID: 8430848
Thanks for the answer.  I deleted the profile and recreated it and now it works.  Only slightly bad thing is that Outlook now has to be running or it still asks for the profile.  I'll just have to make sure and leave outlook running every night.
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

743 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