Dart Home | PowerTCP Mail for ActiveX | Custom Development | Reply | PowerTCP Mail for ActiveX Topics | Forums |
Author | Forum: PowerTCP Mail for ActiveX Topic: newbie question...please help |
htbrady htbrady@hotmail.com From: Wichita, KS USA Posts: 1 Member Since: 01/30/04 |
posted January 30, 2004 4:03 PM I just got assigned a project where I need to go through an email directory and examine all the bounced back emails that came back from bad addresses after a recent email campaign. I need to figure out the bad email address from each message then flag that record in the database. I was wondering if anyone could point me to some code that would get me started or if this control had certain methods built in to do some of the dirty work. I will be using VB6. Can this also be done from a web environment? If so, have any source code? Thank you for your time. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted January 30, 2004 4:32 PM I did something like this once but I don't have a complete project I can give you. The best I can do is post some of the functions. Basically you need to check the sender of each message as best as you can to decide whether the message is returned. I used this function: Private Function IsReturnedMail(ByVal Message As DartMailCtl.Message) As Boolean IsReturnedMail = False Dim From As String From = UCase(Message.From) If InStr(From, "MAIL DELIVERY SUBSYSTEM") Or _ InStr(From, "WEBSHIELD SMTP V4.5 MR1A MAIL SERVICE") Or _ InStr(From, "NORTON_ANTIVIRUS_GATEWAYS") Or _ InStr(From, "MAIL DELIVERY SYSTEM") Or _ InStr(From, "ADMINISTRATOR") Or _ InStr(From, "DAEMON") Or _ InStr(From, "POSTMASTER@") Then IsReturnedMail = True Else Debug.Print From End If End Function You'll have to add other cases as you find them. Once you have all the messages, get the contents then check for an email address. Here are the functions I used to do that: Private Function GetAddressLine(ByVal Message As DartMailCtl.Message) If Message.PartList.Count = 0 Then Dim Lines As New DartStrings Lines.Delimiter = vbCrLf Lines.Add Message.Text GetAddressLine = Lines.Find("To: ") Exit Function End If Dim Part As DartMailCtl.Part For Each Part In Message.PartList If InStr(Part.Header.Find(msgContentType), "message/rfc822") Then GetAddressLine = Part.Parts(1).Header.Find(msgNull, "To: ") Exit For End If If InStr(Part.Header.Find(msgContentType), "text/rfc822-headers") Then Dim p1 As Long Dim p2 As Long p1 = InStr(Part.Data, vbCrLf + "To: ") If p1 > 0 Then p1 = p1 + 6 p2 = InStr(p1, Part.Data, vbCrLf) If p2 > 0 Then GetAddressLine = Mid(Part.Data, p1, p2 - p1) End If End If Exit For End If Next End Function Private Function GetAddress(ByVal s As String) As String Dim amppos As Integer Dim p1 As Integer Dim p2 As Integer Dim n As Integer Dim temp As String amppos = InStr(s, "@") p1 = 1 p2 = Len(s) GetAddress = "" If amppos = 0 Then Exit Function ' find start of address For n = (amppos - 1) To 1 Step -1 temp = Mid(s, n, 1) If (temp = " ") Or (temp = "<") Or (temp = "(") Or (temp = "'") Then p1 = n + 1 Exit For End If Next ' find end of address For n = (amppos + 1) To Len(s) temp = Mid(s, n, 1) If (temp = " ") Or (temp = ">") Or (temp = ")") Or (temp = "'") Then p2 = n - 1 Exit For End If Next ' make address GetAddress = Mid(s, p1, (p2 - p1) + 1) End Function You would use these like so: Dim addr As String addr = GetAddress(GetAddressLine(Pop1.Messages(n))) Be warned that this can be a very tedious process ( which is eventually why I gave up ) because every server returns a different bounce message. Good Luck! |
Reply | PowerTCP Mail for ActiveX Topics | Forums |
This site is powered by
![]() |