schmir1
asked on
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.
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.
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: https://www.experts-exchange.com/questions/20243072/Send-Object.html
Oh yes, and I left out one constant above for the Outlook code:
Dim olFolderInbox : olFolderInbox = 6
Dim olFolderInbox : olFolderInbox = 6
ASKER
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.
Ah, I see. So there is something different about this instance than the others?
ASKER
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.
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.
I suspect you're better off changing your mail routine over to CDO. CDO works with any MAPI mail client.
ASKER
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
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
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
I have found good code samples on this site in the past:
http://www.cdolive.com
ASKER
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.
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.
ASKER
Sounds worth a try. Do you know which file it is?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
If you have Outlook, you could also just instance Outlook using the current user profile:
Dim oOutlookApp, oInbox, oMail
Set oOutlookApp = new ActiveXObject("Outlook.App
Set oInbox = oOutlookApp.GetDefaultFold
Set oMail = oInbox.Items.Add(olMailIte
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.A
'add recipients
Set oRecip = omessage.Recipients.Add("r
oRecip.Resolve
Set oRecip = omessage.Recipients.Add("r
oRecip.Resolve
Set oRecip = omessage.Recipients.Add("r
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.t
.Source = "c:\ComCareExport_051001.t
End With
.Update
End With
'Send the Mail
omessage.Send , showdialog:=False
osession.DeliverNow
osession.Logoff
End Function