MS Office Forum / Outlook / Programming VBA / May 2005
how to get sender's (ISP's) IP adress
|
|
Thread rating:  |
Guy Lateur - 26 May 2005 11:14 GMT Hi all,
I would like to know how I can retrieve the sender's IP adres (or rather, the IP closest to the sender, as found in the Internet Headers in Message Options) from a mail item using VB. I can't seem to find the right property for this. Does anybody know how to do this?
TIA, g
Michael Bauer - 26 May 2005 13:06 GMT Hi,
the OOM doesn´t provide this info and CDO AFAIK also doesn´t. You could use CDO, read the CdoPR_TRANSPORT_MESSAGE_HEADERS and search in that string IP addresses.
 Signature Viele Gruesse / Best regards Michael Bauer - MVP Outlook
> Hi all, > [quoted text clipped - 5 lines] > TIA, > g Guy Lateur - 26 May 2005 15:55 GMT Thanks a lot, Michael, it works!
> Hi, > [quoted text clipped - 14 lines] >> TIA, >> g Dmitry Streblechenko - 26 May 2005 17:54 GMT Note however that there is absolutely no requirement for the sender's IP address to be present in the headers. And if it is there, it could've been easily forged.
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
> Thanks a lot, Michael, it works! > [quoted text clipped - 16 lines] >>> TIA, >>> g Guy Lateur - 27 May 2005 08:30 GMT Thanks for the info. I've indeed noticed that not all messages contain this header info, but I thought that was because they were sent from within our company LAN.
Anyway, does anybody know of a better way to check the (true) origin of mail? We've been getting quite some spam/infected mail here, so I've been putting up some rules in Outlook to block messages based on IP adress (I knew the sender's email adress was fake). Of course, I'd like to check the messages in the user's inbox to make sure I'm not blocking any genuine messages.
Is there anything useful that can't be forged?
> Note however that there is absolutely no requirement for the sender's IP > address to be present in the headers. And if it is there, it could've been [quoted text clipped - 4 lines] > OutlookSpy - Outlook, CDO > and MAPI Developer Tool Dmitry Streblechenko - 27 May 2005 19:33 GMT Nope. Unless your code runs on the server so that it can determine the IP address of the incoming connection, there is no way to do that.
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
> Thanks for the info. I've indeed noticed that not all messages contain > this header info, but I thought that was because they were sent from [quoted text clipped - 17 lines] >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool guy lateur - 27 May 2005 21:54 GMT Allright! That sounds good, because I indeed plan to implement this on the server (win2k3 + exchange). That way my users are completely shielded from this.
One thing, though: we're no longer talking about programming Outlook, then, but Exchange, right? Is that comparable at all? I'm quite new to this all, you see..
Thanks again for your input, guys, much appreciated!
> Nope. Unless your code runs on the server so that it can determine the IP > address of the incoming connection, there is no way to do that. [quoted text clipped - 3 lines] > OutlookSpy - Outlook, CDO > and MAPI Developer Tool Dmitry Streblechenko - 27 May 2005 22:59 GMT I meant not just on the server, your *app* must be the SMTP server that will be accepting messages from the sending server.
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
> Allright! That sounds good, because I indeed plan to implement this on the > server (win2k3 + exchange). That way my users are completely shielded from [quoted text clipped - 13 lines] >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool guy lateur - 27 May 2005 23:31 GMT Oh, I see.. Well, that's too bad, then, because I'm not planning on going quite that deep with this.
It does beg the question, though, why Exchange (being the smpt server you're refering to) doesn't allow me (the admin) to access this info. I mean, is that in itself a security breach or something?
>I meant not just on the server, your *app* must be the SMTP server that >will be accepting messages from the sending server. [quoted text clipped - 13 lines] >> >> Thanks again for your input, guys, much appreciated! Dmitry Streblechenko - 28 May 2005 00:36 GMT You might want to post that question in one of the Exchange newsgroups...
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
> Oh, I see.. Well, that's too bad, then, because I'm not planning on going > quite that deep with this. [quoted text clipped - 20 lines] >>> >>> Thanks again for your input, guys, much appreciated! Guy Lateur - 27 May 2005 15:17 GMT I have another related question. As Dmitry pointed out, not all messages have this header information. Even worse, if a message doesn't contain the info, my script generates a runtime error [MAPI_E_NOT_FOUND(8004010F)] on the following line: InternetHeaders = objFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS).Value
Does anyone know how I can avoid program termination if the headers are not present? So basically, I'd like to check wether or not I can retrieve the headers before actually doing it. Any ideas?
Cheers, g
> Note however that there is absolutely no requirement for the sender's IP > address to be present in the headers. And if it is there, it could've been [quoted text clipped - 4 lines] > OutlookSpy - Outlook, CDO > and MAPI Developer Tool Michael Bauer - 27 May 2005 16:27 GMT In this case, please check whether the requested Field object exists or not, before you access its Value property.
In general, just add error handlers to your code.
 Signature Viele Gruesse / Best regards Michael Bauer - MVP Outlook
> I have another related question. As Dmitry pointed out, not all messages > have this header information. Even worse, if a message doesn't contain the [quoted text clipped - 17 lines] > > OutlookSpy - Outlook, CDO > > and MAPI Developer Tool guy lateur - 27 May 2005 22:00 GMT I'll try that monday at work. I'm not really sure what you mean, though. I've tried IsMissing() et al, but that didn't seem to work.
Is there a function Exists(object) or something? Or are we talking about something like a try-catch thing?
> In this case, please check whether the requested Field object exists or > not, before you access its Value property. > > In general, just add error handlers to your code. Michael Bauer - 28 May 2005 07:40 GMT You could use something like this:
On Error Resume Next Dim oField as Mapi.Field Set oField=objFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS) If oField is Nothing then Err.Clear ' Field doesn´t exist Else InternetHeaders = objFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS).Value Endif
 Signature Viele Gruesse / Best regards Michael Bauer - MVP Outlook
> I'll try that monday at work. I'm not really sure what you mean, though. > I've tried IsMissing() et al, but that didn't seem to work. [quoted text clipped - 6 lines] > > > > In general, just add error handlers to your code. Guy Lateur - 30 May 2005 17:29 GMT Thanks, mate!
> You could use something like this: > [quoted text clipped - 8 lines] > objFields.Item(CdoPR_TRANSPORT_MESSAGE_HEADERS).Value > Endif
|
|
|