Why cannot CDO Object for SMTP accept Mail.Sender.SMTPAddress object as .to property?

108 Views Asked by At

I am reading senduser emails with Redemption library and trying to send the email through SMTP CDO.Object.

I have been receiving following error, as long as I get the email for "EX" senderEmailType through Mail.Sender.SMTPAddress: CDO.Message.1: The transport lost its connection to the server.

Here is my code snippet (will lead to an error as long as mailReceiver argument is taken through Mail.Sender.SMTPAddress Redemption property - even converted to string it leads to the same error - cStr(Mail.Sender.SMTPAddress)) Although when I change the mailReceiver Property to the same email as string - it does not generate any error like this (maiLReceiver = "[email protected]"):

sub sendMailSMTP(mailSubject, mailSender, mailReceiver, CC, BCC, replyTo, HTMLBody, attachmentsPath_List, REMOTE_SMTP, SMTP, PORT_SMTP, SCHEMAS)
HTML_CID = ""
set CDOObject = CreateObject("CDO.Message")
with CDOObject
    .subject = mailSubject
    .from = mailSender
    .to = mailReceiver
    .CC = CC
    .BCC = BCC
    .replyTo = replyTo
    .HTMLBody = HTMLBody & HTML_CID
    .TextBodyPart.Charset = "utf-8"
    .AddAttachment LOGO_MAIL
    .Attachments(1).Fields.Item("urn:schemas:mailheader:content-disposition") ="attachment;filename="& replace(split(LOGO_MAIL, "\")(ubound(split(LOGO_MAIL, "\"))),".jpg","")
    .Attachments(1).Fields.Update
    for each attachmentPath in attachmentsPath_List
        .AddAttachment attachmentPath
    next
end with

with CDOObject.Configuration.Fields
    .Item(SCHEMAS & "sendusing") = REMOTE_SMTP
    .Item(SCHEMAS & "smtpserver") = SMTP
    .Item(SCHEMAS & "smtpserverport") = PORT_SMTP 
    .Item(SCHEMAS & "smtpconnectiontimeout") = 60
    .Update
end with 
CDOObject.Send
set CDOObject = Nothing
end sub 

Could anyone point me to the right direction, what may be the reason for that?

0

There are 0 best solutions below