Archived Forum Post

Index of archived forum posts

Question:

MXLOOKUP not working

Nov 27 '12 at 19:57

Hi, I am trying to perform mxlookup using mailman. Here goes the code:

    Dim mailman As New Chilkat.MailMan()
    mailman.UnlockComponent("My Code")
    Dim mailServerHostname As String
    mailServerHostname = mailman.MxLookupAll("yahoo.ca").GetString(1)
    if mailserverhostname is nothing then mailserverhostname="failed."
    TextBox1.Text = mailServerHostname

The code is working fine for yahoo.com or gmail.com but not working for yahoo.ca

How can i resolve this? Is it a bug?

Thanks.


Answer

MxLookupAll returns a Chilkat.StringArray object. Just because the word "Array" is in the name of a class does not mean it's an array. A Chilkat.StringArray is an object that contains a collection of strings which may be accessed via an index, not as an array, but via the GetString(index) method call.

For example:

Dim mailman As New Chilkat.MailMan()
mailman.UnlockComponent("My Code")
Dim sa As Chilkat.StringArray
sa = mailman.MxLookupAll("yahoo.ca")
if sa is nothing then
...
else
    TextBox1.Text = sa.GetString(0)
end if