Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 728
  • Last Modified:

Don't want SendObject to brings Choose Profile Dialog box

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
schmir1
Asked:
schmir1
  • 8
  • 6
1 Solution
 
rherguthCommented:
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
 
rherguthCommented:
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
 
rherguthCommented:
Oh yes, and I left out one constant above for the Outlook code:
Dim olFolderInbox : olFolderInbox = 6
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
schmir1Author Commented:
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
 
rherguthCommented:
Ah, I see.  So there is something different about this instance than the others?
0
 
schmir1Author Commented:
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
 
rherguthCommented:
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
 
schmir1Author Commented:
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
 
rherguthCommented:
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
 
schmir1Author Commented:
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
 
rherguthCommented:
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
 
schmir1Author Commented:
Sounds worth a try.  Do you know which file it is?
0
 
rherguthCommented:
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
 
schmir1Author Commented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now