sending email automatically prob with Outlook XP

CraigLazar
CraigLazar used Ask the Experts™
on
Hi
I need help please
i am trying to send a email automatically, this is the code i am useing, it uses
the default mail client about Outlook XP
this is the code


MAPISession1.SignOn                                     'Open up a MAPI session:

MAPIMessages1.SessionID = MAPISession1.SessionID        'Point the MAPI messages control to the open MAPI session:
MAPIMessages1.Compose                                   'Start a new message
MAPIMessages1.MsgSubject = MailSubject                  'Set the subject of the message:
MAPIMessages1.MsgNoteText = MailMsg
For i = 0 To (MailCount - 1)
    MAPIMessages1.RecipIndex = i                        'First recipient
    MAPIMessages1.RecipType = 1                         'Recipient in TO line
    MAPIMessages1.RecipDisplayName = MailAddress(i)      'e-mail name
Next i
MAPIMessages1.ResolveName
MAPIMessages1.Send                                      'Send the message:
MAPISession1.SignOff                                    'Close MAPI mail session:


If Outlook is closed, then i get a box that pops up asking for the profile
i ticked the checkbox for use this as the default but if i then close outlook, run my little app
it comes up with this box, however if outlook is running, then i do not get this box
it connects and sends the mail

any ideas ?


thanx

Craig
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Hi,

Try starting the Session like this:

mapiSession1.UserName = strUserName 'Your name
mapiSession1.Password = strPassword 'Your password
mapiSession1.LogonUI = False 'Hide the GUI
mapiSession1.NewSession = True 'Never recycle old sessions
mapiSession1.SignOn

Hope this helps ...
Commented:
I would suggest you to use this component instead of MAPI. It is easier to use and the hassles involved are very low. It is a free component. http://www.freevbcode.com/ShowCode.Asp?ID=109

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial