?
Solved

Avoiding "Choose Profile" box with Access'  Sendobject

Posted on 2003-02-25
3
Medium Priority
?
284 Views
Last Modified: 2009-12-16
This is from several years ago, and I have a follow-up question:
--------------------------------------------------
Hi,
i have a sub that uses SendObject action to mail me a message.  It works ok but how do i get it to not pop up the "Choose Profile" window, is this some option in IE (outlook) or is it part of MAPI. what ever the case how can i get it to not popup like that. Any help would be great.  

View Accepted Answer

 
Question History
Accepted Answer from ramrom  03/14/1998 06:48PM PST  
A long answer: use the following subroutine in lieu of SendObject. It creates a MAPI session and a MAPI message.
The combination of:
MapiSession.Logon profilename:="MS Exchange Settings"
and
.Send showdialog:=false
suppress the window.
Code commented out adds stuff to the message. The active code is what it takes to send a simple text message to 1 recipient.

Sub SendMAPIMessage()
 Dim MapiSession As Object
 Dim MapiMessage As Object
 Dim MapiRecipient As Object
 Dim MapiAttachment As Object
 Dim Recpt, errObj As Long, errMsg
 On Error GoTo MAPITrap        ' Create the MAPI Session.
 Set MapiSession = CreateObject("Mapi.Session")
 ' Log on to the session
 MapiSession.Logon profilename:="MS Exchange Settings"
 ' Add a message to the Outbox.
 Set MapiMessage = MapiSession.Outbox.Messages.Add
 ' Add the recipients of the message. Note, each recipient must be
 ' added separately to the Recipients collection of the Message
 ' object.
 With MapiMessage
   Set MapiRecipient = MapiMessage.Recipients.Add
   MapiRecipient.Name = "ramrom@earthling.net"
   MapiRecipient.type = mapiTo
   'Set MapiRecipient = MapiMessage.Recipients.Add
   'MapiRecipient.Name = "Andrew Fuller"
   'MapiRecipient.type = mapiCc
   'Set MapiRecipient = MapiMessage.Recipients.Add
   'MapiRecipient.Name = "Michael Suyama"
   'MapiRecipient.type = mapiBcc
   ' Resolve each recipient's e-mail name.
   For Recpt = 0 To .Recipients.Count - 1
     .Recipients(Recpt).Resolve showdialog:=True
   Next
   ' Attach a file to the message.
   'Set MapiAttachment = MapiMessage.Attachments.Add
   'With MapiAttachment
   '  .Name = "Customers.txt"
   '  .type = mapiFileData
   '  .Source = "C:\Examples\Customers.txt"
   '  .ReadFromFile FileName:="C:\Examples\Customers.txt"
   '  .position = 2880
   'End With
   ' Assign the text, subject, and importance of the message.
   .subject = "My Subject"
   .Text = "This is the text of my message." & vbCrLf & vbCrLf
   .importance = mapiHigh
   ' View the message in Microsoft Exchange before sending. Set
   ' the ShowDialog argument to False if you want to send the
   ' message without viewing it in Microsoft Exchange.
   .Send showdialog:=False
 End With
 Set MapiSession = Nothing  ' Clear the object variable.

MAPIExit:
 Exit Sub

MAPITrap:
 errObj = Err - vbObjectError  ' Strip out the OLE automation error.
 Select Case errObj
  Case 275                  ' User cancelled sending of message.
   Resume MAPIExit
  Case Else
   errMsg = MsgBox("Error " & errObj & " was returned.")
   Resume MAPIExit
 End Select
End Sub

-------------------------------------------------------

The question: This works for me as is, but how do I insert an attachment in the email.

Thanks for any help.


0
Comment
Question by:pmurray928
[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
3 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 200 total points
ID: 8018683
It's an option in Outlook. Open Control Panel, and go to Mail. If you are using Outlook 2000 or later, click on the "Show Profiles" option. You should then see a screen with "Prompt for Profile" or "Always use this Profile".

To remove the prompt, select the second option, and choose your profile. Be careful if you have multiple e-mail profiles set up.
0
 
LVL 18

Expert Comment

by:1William
ID: 8742636
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept question, points to shanesuebsahakarn
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
1William
EE Cleanup Volunteer
0

Featured Post

 [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

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

765 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