With the change I indicated in your code, it worked here without a problem.
Please respond only to the newsgroups so all can benefit.
> Randy,
> Thank you for your response. I already assigned the SessionID in another
> function named "openSession" and called that in SendMail function. Here is
> the complete code. Please advice.
> Thanks
> Chandu
> ********************************************************************
> Private Function openSession() As Boolean
> ' Opens the MAPI session for processing mail
> openSession = False ' assume failute until end of function
> On Error GoTo openSessionError
> MAPISession1.SignOn
> MAPIMessages1.SessionID = MAPISession1.SessionID
> openSession = True ' Got here, so success!
> Exit Function
> openSessionError:
> MsgBox Err.Description
> Err.Clear
> End Function
> > > *******************************************************
> > > Public Function SendEmail(Recipient As String, CC As String, BCC As
> > String,
> > > Subject As String, Body As String, Optional Attachment As String = "")
> As
> > > Boolean
> > > On Error GoTo SendEmailError
> > > SendEmail = False
> > > If Not openSession Then Exit Function
> > > With MAPIMessages1
> > > .MsgIndex = -1
> > > .Compose
> > > .RecipDisplayName = Recipient
> > > .RecipAddress = Recipient
> > > .MsgSubject = Subject
> > > .MsgNoteText = Body
> > > .ResolveName
> > > If Len(CC) > 0 Then
> > > '* CARBON COPY (CC) ADDRESS
> > > .RecipIndex = .RecipIndex + 1
> > > .RecipType = mapCcList
> > > .RecipDisplayName = CC
> > > .RecipAddress = .RecipDisplayName
> > > End If
> > > If Len(BCC) > 0 Then
> > > '* CARBON COPY (BCC) ADDRESS
> > > .RecipIndex = .RecipIndex + 1
> > > .RecipType = mapBccList
> > > .RecipDisplayName = BCC
> > > .RecipAddress = .RecipDisplayName
> > > End If
> > > '* Show the address book with the selected recipient(s)
> > > .AddressEditFieldCount = 3 '0=no edit fields, 1=TO, 2=(TO
and
> > > CC), 3=(TO, CC and Blind CC), 4=only those supported by messaging
system
> > > will be shown
> > > .MsgNoteText = Body
> > > .Send
> > > End With
> > > MAPISession1.SignOff
> > > SendEmail = True
> > > Exit Function
> > > SendEmailError:
> > > MsgBox Err.Description
> > > Err.Clear
> > > On Error Resume Next
> > > MAPISession1.SignOff ' Ensure session not left open!
> > > If Err.Number <> 0 Then Err.Clear
> > > End Function
> ***************************************Code End***************************
> > You're not assigning the session ID to the message ... add as the first
> line
> > under the With block ...
> > With MAPIMessages1
> > .SessionID = MAPISession1.SessionID
> > --
> > Randy Birch
> > MVP Visual Basic
> > http://www.mvps.org/vbnet/
> > Please respond only to the newsgroups so all can benefit.
> > *** If you call the Sleep API in Bill's latest, will it have .NET
dreams?
> > ***
> > > Hi,
> > > I am writing an email client application. It is able to send mail to
TO:
> > > address only, but failing to send thru CC and BCC. To the email
address
> > > mentioned in CC address, bounced mail shows the following error
> > > " No transport provider was available for delivery to this
> > recipient.".
> > > I am calling a function called SendEmail() to send mail. Here by I am
> > > attaching the code. Please have a look and let me know if any one have
> > idea.
> > > Or If you have any other examples with similar functionality please
give
> > me
> > > the references.
> > > Thanks
> > > Chandra
> > > *******************************************************
> > > Public Function SendEmail(Recipient As String, CC As String, BCC As
> > String,
> > > Subject As String, Body As String, Optional Attachment As String = "")
> As
> > > Boolean
> > > On Error GoTo SendEmailError
> > > SendEmail = False
> > > If Not openSession Then Exit Function
> > > With MAPIMessages1
> > > .MsgIndex = -1
> > > .Compose
> > > .RecipDisplayName = Recipient
> > > .RecipAddress = Recipient
> > > .MsgSubject = Subject
> > > .MsgNoteText = Body
> > > .ResolveName
> > > If Len(CC) > 0 Then
> > > '* CARBON COPY (CC) ADDRESS
> > > .RecipIndex = .RecipIndex + 1
> > > .RecipType = mapCcList
> > > .RecipDisplayName = CC
> > > .RecipAddress = .RecipDisplayName
> > > End If
> > > If Len(BCC) > 0 Then
> > > '* CARBON COPY (BCC) ADDRESS
> > > .RecipIndex = .RecipIndex + 1
> > > .RecipType = mapBccList
> > > .RecipDisplayName = BCC
> > > .RecipAddress = .RecipDisplayName
> > > End If
> > > '* Show the address book with the selected recipient(s)
> > > .AddressEditFieldCount = 3 '0=no edit fields, 1=TO, 2=(TO
and
> > > CC), 3=(TO, CC and Blind CC), 4=only those supported by messaging
system
> > > will be shown
> > > .MsgNoteText = Body
> > > .Send
> > > End With
> > > MAPISession1.SignOff
> > > SendEmail = True
> > > Exit Function
> > > SendEmailError:
> > > MsgBox Err.Description
> > > Err.Clear
> > > On Error Resume Next
> > > MAPISession1.SignOff ' Ensure session not left open!
> > > If Err.Number <> 0 Then Err.Clear
> > > End Function