Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate internal email address using CDO?

Status
Not open for further replies.

MikeAuz1979

Programmer
Aug 28, 2006
80
AU
Hi,

Using Access 2000 I'm using CDO to send emails to internal staff via their payroll number. (Our outlook is configured so you can send emails using payroll number.)

This all works fine but the system that I'm pulling the payroll number from is truncating the 6 digit number to 4 digits (As payroll numbers used to be 4 digits and are now 6)

The good news is that each 4 digit truncation of 6 digit payroll number is unique and the bad news is that I can't just add a suffix such as 01 to the end as this isn't always the case.

So what I need is a way of validating the .TO address against what's in our exchange so it can complete the address. (For example a payroll number of 500902 is being truncated to 5009, which I want to put into the .TO box and then have CDO validate it to find the 02 part and the result being the full payroll number 500902)

As always thanks for any help
[To the gurus out there an FAQ covering all aspects of CDO would be awesome!]
Mike




---Code Start---
Sub SendMail_CDO(Recip As Variant, AcctMgr As Variant, SITE As String, PMDQ As Boolean, DestFile)
'Sends directly from the Major Customers group mailbox, undelivered's return there and a rule
'on the box moves these mails to the SentItems folder

Dim iMsg As Object
Dim iConf As Object
Dim strbody, subject As String
Dim Flds As Variant

If PMDQ = True Then
subject = "Proposed Daily OverRun for Site " & SITE
bodytext = "Hi," & vbCrLf & "The Site " & SITE & " had an Proposed MDQ overrun for yesterday."
Else
subject = "Daily OverRun for Site " & SITE
bodytext = "Hi," & vbCrLf & "The Site " & SITE & " had an overrun yesterday."
End If

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item(" = 2
.Item(" = "Test.aol.int"
.Item(" = 25
.Update
End With

With iMsg
Set .Configuration = iConf
.To = Recip
.CC = AcctMgr
.BCC = "Test@aol.com.au"
.FROM = "Test@aol.com.au"
.TextBody = bodytext
.subject = subject
If Not IsEmpty(DestFile) And Not IsNull(DestFile) Then
.AddAttachment DestFile
End If
.Send
End With

Set iMsg = Nothing
Set iConf = Nothing
End Sub
---Code End---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top