MAPI - Not able to send mails thru CC and BCC 
Author Message
 MAPI - Not able to send mails thru CC and BCC

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



Sun, 05 Sep 2004 22:08:36 GMT  
 MAPI - Not able to send mails thru CC and BCC
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?
***


Quote:
> 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



Mon, 06 Sep 2004 12:27:29 GMT  
 MAPI - Not able to send mails thru CC and BCC
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

Quote:
> > *******************************************************
> > 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***************************


- Show quoted text -

Quote:
> 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



Mon, 06 Sep 2004 21:39:16 GMT  
 MAPI - Not able to send mails thru CC and BCC
With the change I indicated in your code, it worked here without a problem.

--

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?
***


Quote:
> 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



Tue, 07 Sep 2004 07:02:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. CC and BCC using MAPI

2. MAPI CC or BCC

3. How to send a copy BCC instead of CC in Outlook Rules Wizard

4. after sending rules BCC instead CC possible?

5. SMTP: How to send CC and BCC?

6. MAPI & CC:Mail

7. MAPI - Exchange Server does not send e-mail message

8. MAPI ,E-mail can not send

9. MAPI - Sending a mail message to a recip NOT in any address book

10. MAPI - Sending a mail message to a recip NOT in any address book

11. VB 4.0 MAPI Control cc:Mail

12. MAPI, VIM, and cc: Mail

 

 
Powered by phpBB® Forum Software