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
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 = ""