Archived Forum Post

Index of archived forum posts

Question:

Can't get Cc Name or anything in visual basic

Jan 29 '13 at 15:27

Visual Basic MSaccess 2007

Hi,

I can't seem to get any value from the Cc of an email.

The emails definitely have a Cc address & name, although I can't see any reference to it in the header that is brought down by chilkat, I can see it in the source via thunderbird.

See last line of below, tried a dozen or so email from a variety of sources & I just get nothing "" from all of the getCC... "<><><>" All the other info is there fine, names, date header etc etc. Most of my test examples were NOT gmail so don't think this is to blame.

Dim bundle As ChilkatEmailBundle2 Set bundle = imap.FetchBundle(messageSet) If (bundle Is Nothing) Then

MsgBox imap.LastErrorText
Exit Sub

End If

' Display the Subject and From of each email. Dim i As Long For i = 0 To bundle.MessageCount - 1 Dim Email As ChilkatEmail2 Set Email = bundle.GetEmail(i)

Me.Subject = Email.Subject
Me.From = Email.From

bText = Email.HasPlainTextBody()
If (bText) Then
    Me.Contents = Email.GetPlainTextBody() ' gmail etc includes html stuff in Body so check if also has plaintext, if so use this
    Else: Me.Contents = Email.Body
End If

Me.Received = Email.EmailDate 
Me.HeaderComplete = Email.Header

MsgBox ">" & Email.GetCC(i) & "<>" & Email.GetCcName(i) & "<>" & Email.GetCcAddr(i)

What I am trying to achieve is when I reply to an email in my Access Database I Cc it with my email so I get a copy, but I want this copy to be moved to another imap folder. So new unread emails come in and get processed by my database but if it is an unread email but with a "me cc" it DOES NOT get processed but simply moved to "MySent" I had wondered if this achieved in a better way but thought I would start here but now spent some hours and not even found a way to even read a Cc. I have your latest ChilkatImap because of the "ckx-imap-uid" Bug where I could not read the some of the header.


Answer

Solved, As soon as I posted I noticed what I had done,

Needed separate loop & counter for the CC, I was taking the overall i get bundle loop,

I was staring at it for ages and could not see it but was obvious when I read what I had posted here.

What a twit!


Answer

Each email can have 0 or more "To" recipients, and 0 or more "CC" recipients. The NumTo and NumCC properties indicate how many. Your program would loop from 0 to NumCC-1, calling GetCC(idx), GetCcName(idx), etc. for each of the CC recipients.

You're using the index "i" which makes no sense. In your code snippet, the index "i" is the Nth email in the bundle.