?
Solved

Sending X400 mails using CDO

Posted on 2003-03-07
7
Medium Priority
?
626 Views
Last Modified: 2012-06-21
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
Comment
Question by:craZcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:iozturk
ID: 8088463
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
 
LVL 4

Expert Comment

by:iozturk
ID: 8088506
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
 

Author Comment

by:craZcoder
ID: 8100769
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.

 

Author Comment

by:craZcoder
ID: 8101334
Better still, can anyone tell me how to convert legacy addresses (X400, LDAP, DN etc) to SMTP address?

Thanks!!
Z.
0
 

Expert Comment

by:CleanupPing
ID: 8900523
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
 
LVL 4

Accepted Solution

by:
iozturk earned 90 total points
ID: 8900937
Since, only I gave answer the question points shoul go to me.
0
 

Author Comment

by:craZcoder
ID: 8901233
I hv given the points to iozturk, even though my question was not answered completely.
Thanks,
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question