Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 635
  • Last Modified:

Sending X400 mails using CDO

Hi,
I m using CDOEx for sending mails. It works fine for SMTP addresses, but doesnt work for X400 address.
Here is a sample X400 address.
[X400:c=us;a= ;p=sss;o=chn;s=sysexhwnt;]
The problem with CDO is, it treats the above as a SMTP address and tries to separate it into different IDs at the semi-colons.
Do you know any properties to specify that the address is an X400 or LDAP or SMTP address inorder to avoid this parsing?
I am not sure where to put this query, since I m using VB, hence I have put it here. Let me know if I need to put it elsewhere.
Thanks in advance,
Z.

0
craZcoder
Asked:
craZcoder
  • 3
  • 3
1 Solution
 
iozturkCommented:
X400 mails are different from smtp's. To send x400 mails you need to logon to the exchange server before sending it.

Here is an example that works for logon user account
add dont forget to add micsosoft CDO library from references.

Private sub fSendMail()
  Dim objsession As mapi.Session
  Dim objmessage As mapi.Message
  Dim objnewAttachment, objOneRecip
  Dim file_name, file_path
  Dim fso As Scripting.FileSystemObject
 

  On Error Resume Next
   
    If Err.Number <> 0 Then
        fSendMail = False
        Exit Function
    End If
   Set objsession= CreateObject("MAPI.Session")
   bstrProfileInfo = server + vbLf + kulemailx
   'change the parameters to valid values for your   configuration
   objsession.Logon , , , True, , True, bstrProfileInfo
    ' create a message and fill in its properties
    Set objmessage = objsession.Outbox.Messages.Add    
    objmessage.Subject = konu + " (Helpdesk)"
    objmessage.Text = mesaj + vbCrLf + CStr(Now)
    file_name = objability.fFindAttachment(pno)
    'writelog file_name
    If file_name <> "0" Then
       Set fso = CreateObject("scripting.Filesystemobject")
       If fso.FileExists(UploadPath + file_name) Then
           Set objnewAttachment = objmessage.Attachments.Add
           objnewAttachment.Name = file_name
           objnewAttachment.Source = UploadPath + file_name
           objnewAttachment.Type = 1
           objnewAttachment.ReadFromFile (UploadPath + file_name)
       End If
       Set fso = Nothing
    End If

    'create the recipient
    Set objOneRecip = objmessage.Recipients.Add
    objOneRecip.Name = isim
    'objOneRecip.Type = CdoTo
    objOneRecip.Resolve ' get MAPI to determine complete e-mail address
 
    ' send the message and log off
    If kulgrup = 5 Then
        objmessage.DeliveryReceipt = True
        objmessage.ReadReceipt = True
    End If
    objmessage.Send False, False, 0
       
    If Err.Number <> 0 Then
        ' log it
    End If
   

End Function
0
 
iozturkCommented:
sorry, you need some modifications on that. here is it

Private sub fSendMail(file_name)
  Dim objmessage As mapi.Message
  Dim objnewAttachment, objOneRecip
  Dim file_name, file_path
  Dim fso As Scripting.FileSystemObject
 
  On Error Resume Next


   
    If Err.Number <> 0 Then
        fSendMail = False
        Exit Function
    End If
    Set mysession = CreateObject("MAPI.Session")
    bstrProfileInfo = server + vbLf + "yourusername" 'take user name from wscript.network
   'change the parameters to valid values for your configuration
    mysession.Logon , , , True, , True, bstrProfileInfo

    ' create a message and fill in its properties
    Set objmessage = objsession.Outbox.Messages.Add
   
    objmessage.Subject = "ypur subject"
    objmessage.Text = mesaj + vbCrLf + CStr(Now)
       
    If file_name <> "0" Then
       Set fso = CreateObject("scripting.Filesystemobject")
       If fso.FileExists(UploadPath + file_name) Then
           Set objnewAttachment = objmessage.Attachments.Add
           objnewAttachment.Name = file_name
           objnewAttachment.Source = UploadPath + file_name
           objnewAttachment.Type = 1
           objnewAttachment.ReadFromFile (UploadPath + file_name)
       End If
       Set fso = Nothing
    End If

    'create the recipient
    Set objOneRecip = objmessage.Recipients.Add
    objOneRecip.Name = "recipientusername"
    'objOneRecip.Type = CdoTo
    objOneRecip.Resolve ' get MAPI to determine complete e-mail address
 
    ' send the message and log off
   
    objmessage.DeliveryReceipt = True
    objmessage.ReadReceipt = True
   
    objmessage.Send False, False, 0
       
    If Err.Number <> 0 Then
        ' log it
    End If
   

End Sub
0
 
craZcoderAuthor Commented:
Thanks iozturk for the post. This works, however I need to use CDOEx only as per the design specification. Can you tell me if this is possible?
Also I need to attach some .log files and rename them before sending the mail. The problem is when I try to rename the file say Error.Log, it is changed to error.log.dat.
Any ideas?

Thanks,
Z.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
craZcoderAuthor Commented:
Better still, can anyone tell me how to convert legacy addresses (X400, LDAP, DN etc) to SMTP address?

Thanks!!
Z.
0
 
CleanupPingCommented:
craZcoder:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
iozturkCommented:
Since, only I gave answer the question points shoul go to me.
0
 
craZcoderAuthor Commented:
I hv given the points to iozturk, even though my question was not answered completely.
Thanks,
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now