Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 13th, 2008, 03:12 AM
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to send email for more than 1recipient

Hi,,,,

I have my vb application that sends emails..
My problem is that I want to send the email to 1 recipient and sometimes to more than 1 recipient ..
My code will send to 2 emails but when the text boxes are cleared and I want to send again
I get this error message: Invalid session
Code:
.ResolveName
How can I send to multiple users without getting this error?
and if I can insert the emails in one text box without having to insert them in to text boxes?

This is my code:
Code:
 With MAPIMessages1

           .Compose
           .MsgSubject = txtSubject.Text

           '.RecipDisplayName = txtTo.Text
           '.ResolveName
.RecipIndex = 0
.RecipDisplayName = txtTo.Text
.RecipAddress = txtTo.Text
.RecipType = 1
.ResolveName

.RecipIndex = 1
.RecipDisplayName = txtTo1.Text
.RecipAddress = txtTo1.Text
.RecipType = 1
.ResolveName
           'The value 2 is passed to the Space() function in the
           'next line because there are two attachments to add.
           'These spaces act as placeholders for the attachments.
           .MsgNoteText = Space(2)

           'Replace the AttachmentPathName values below as applicable...
         '  .AttachmentIndex = 0
         '  .AttachmentPosition = 0
           If txtAttach.Text <> vbNullString Then
           .AttachmentPathName = txtAttach.Text
          .AttachmentIndex = 1
           .AttachmentPosition = 1
           .AttachmentPathName = txtAttach.Text
           End If

          If txtAttach1.Text <> vbNullString Then
           .AttachmentPathName = txtAttach1.Text
          .AttachmentIndex = 1
           .AttachmentPosition = 1
           .AttachmentPathName = txtAttach1.Text
           End If

           .Send
       End With
MsgBox "Sent"
       MAPISession1.SignOff

txtFrom.Text = ""

txtTo.Text = ""
txtTo1.Text = ""

txtSubject.Text = ""

txtMessage.Text = ""
txtAttach.Text = ""
txtAttach1.Text = ""
 
Old March 13th, 2008, 02:37 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Delimit the email addresses with semicolons.

If you don't want the various people to see eachothers' addresses, put the delimited list in the BCC category, and put yourself in the To: box.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to send email garrettbrennan Visual C++ 0 September 13th, 2007 12:24 PM
How to send email abiye49 Excel VBA 1 January 10th, 2007 03:32 PM
Send by email tsimsha Classic ASP Databases 1 October 1st, 2005 03:03 AM
Send email Danny_n BOOK: Excel 2003 VBA Programmer's Reference 0 January 12th, 2005 08:32 AM
send email X-Ken VS.NET 2002/2003 8 July 2nd, 2004 06:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.