multiple email - error is unknown recipient

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cuatanic
    New Member
    • Jan 2012
    • 2

    multiple email - error is unknown recipient

    my recipients' address to be imported from a database to a textbox. but i keep on getting an error of unknown recipient. please help me with this.

    these are my codes for my send button so far

    Code:
    Dim StartPos, Counter As Integer
        Dim FindString, ReplaceText As String
        FindString = "       "
        ReplaceText = " ; "
         
        For Counter = 1 To Len(address.Text)
                StartPos = InStr(address.Text, FindString)
                If StartPos > 0 Then
                        address.SelStart = StartPos - 1
                        address.SelLength = Len(FindString)
                        address.SelText = "" + ReplaceText
                End If
        Next
        
        
     Dim s
            Dim se() As String
            Dim InputContainer As String
            InputContainer = address.Text
            se() = Split(InputContainer, " ; ")
            Dim i As Integer
            ListView1.ListItems.clear
            For i = 0 To UBound(se)
            Set s = ListView1.ListItems.add(, , se(i))
            Next
    
    MAPISession1.SignOn
    MAPIMessages1.SessionID = MAPISession1.SessionID
    'Compose new message
    MAPIMessages1.Compose
    
    'Create the message
    MAPIMessages1.MsgSubject = subj.Text
    MAPIMessages1.MsgNoteText = body.Text
    
    'Address message
    Const SESSION_SIGNON = 1
          Const MESSAGE_COMPOSE = 6
          Const ATTACHTYPE_DATA = 0
          Const RECIPTYPE_TO = 1
          Const RECIPTYPE_CC = 2
          Const MESSAGE_RESOLVENAME = 13
          Const MESSAGE_SEND = 3
          Const SESSION_SIGNOFF = 2
    
    Dim q As Integer
    Dim w As Integer
    
    q = 0
    w = 0
    
    Do While q < 3 And w < 3
    MAPIMessages1.RecipIndex = q                    'First recipient
    MAPIMessages1.RecipType = RECIPTYPE_TO          'Recipient in TO line
    MAPIMessages1.RecipDisplayName = se(w)
    q = q + 1
    w = w + 1
    Loop
    
    MAPIMessages1.Action = MESSAGE_RESOLVENAME
    'Send the message:
    MAPIMessages1.Action = MESSAGE_SEND
    MAPISession1.SignOff
    thank you. i really appreciate your help.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Could you give us a bit more background information? For example, what is the value in address at the start of this code? Have you traced the code to determine exactly what it's doing? For instance, how has the value changed by line 14? Are you seeing the expected list in ListView1?

    A very important part of the debugging process is to zero in and isolate the source of the problem. So for example, you need to ensure that you're starting with the expected data, and that your initial text replacement is working as expected. (Note, you may find you can achieve it quicker and more simply by using the Replace() function).

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      P.S. Are you aware that you're defining variables StartPos and FindString as (probably) type Variant? From the code, it looks as though you meant them to be Integer and String respectively, but it doesn't work like that. The "As Integer" (or whatever) only applies to the one specific variable.

      I doubt this is a problem, just thought I'd mention it.

      Comment

      Working...