Hi,
Can anybody give me a code how to do this:
Catch all emails adressers from outlook.
Sent to all catched emails message with app.exe
Can anybody help me???
Please.
Printable View
Hi,
Can anybody give me a code how to do this:
Catch all emails adressers from outlook.
Sent to all catched emails message with app.exe
Can anybody help me???
Please.
You can use CDONTS. Go to www.wrox.com and do a search for CDONTS and download the code for this book. That has plenty of samples.Hope that it helps.
'This will work to get all addresses - reference Outlook 8 or 9
Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim adl As Outlook.AddressList
Dim ade As Outlook.AddressEntry
Dim aPAB() As Variant
Dim i As Integer
ReDim aPAB(100, 2)
Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")
'Return the at home personal address book.
Set adl = ns.AddressLists("Contacts")
'This should work from work
'Set adl = ns.AddressLists("Personal Address Book")
'Loop through all entries in the PAB
' and fill an array with some properties.
For Each ade In adl.AddressEntries
'Display name in address book.
aPAB(i, 0) = ade.Name
'Actual e-mail address
aPAB(i, 1) = ade.Address
'Type of address ie. internet, CCMail, etc.
aPAB(i, 2) = ade.Type
i = i + 1
Next
ReDim aPAB(i - 1, 2)
Set ol = Nothing
Set ns = Nothing
Set adl = Nothing
==============
' to send a mail
Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem
Set ol = New Outlook.Application
'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")
ns.Logon
'Create a new mail message item.
Set newMail = ol.CreateItem(olMailItem)
With newMail
'Add the subject of the mail message.
.Subject = "blah blah blah"
'Create some body text.
.Body = "blah blah blah"
'Add a recipient and CC and test to make sure that the
'addresses are valid using the Resolve method.
With .Recipients.Add("[email protected]")
.Type = olTo
If Not .Resolve Then
MsgBox "Unable to resolve address: TO", vbInformation
Exit Sub
End If
End With
With .Recipients.Add("[email protected]")
.Type = olCC
If Not .Resolve Then
MsgBox "Unable to resolve address: CC", vbInformation
Exit Sub
End If
End With
'Attach a file as a link with an icon.
With .Attachments.Add("c:\autoexec.bat")
.DisplayName = "Training info"
End With
'Send the mail message.
.Send
End With
ns.Logoff
'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
HTH
John
Patoooey, sorry, but you code does not work. I'm using Outlook v. 9. If not hard please make a form which demonstates this code.
Thank you.
Making a Form won't help you. That code is taken from an Outlook class I have which uses no forms. There are no controls or visual aids for this code. All work is done with the Outlook 9.0 Object model behind the scenes.
When you say it doesn't work, what is it doing or saying ??
I need exact error messages in order to help.
John
I wanted olny a demo project which demonstrates that code. I inserted this code to Form_Load section and it didn't worked, so I want an example.
Create a new form. Place 1 commandbutton on it. Place the Send Mail code in the click event. You then need to actually look at the code and make the changes you want. Mail Address, Subject, Mail Body, etc. When you click the button, mail should be sent to the address you specify.
As far as the Address code.....what you do with the array of addresses is up to you. My creating a form won't help you.
You are referencing Outlook 8 or 9 right ???
Again.....what is the error ? Outlook/VB always give an error message.
John
The error is in Dim ol As Outlook.Application - Compile Error: User defined type not defined.
I'm using Outlook 9
What is the problem?
confused:
Perhaps, er, , Outlook object library might need to be referenced ?...confused:
Norkis, are you trying to write a virus ?
Nice one Jamie, I had the same thought....
Though it could in theory be totally legit.
Doubt it tho ;)
Yeah I mean :
He could be collecting everyones email addresses to make a nice e-collage or something like that for Tony Hart's gallery.......or could he...?
*cue the hooded claw*
If he can't figure out how to reference a library, then creating a virus is not in his tool-kit.
There is NO Outlook 9. The versions of Outlook are 95, 97, 98 and 2000. When I say REFERENCE Outlook 9, I mean you need a reference in VB to the Outlook 9 object model. That is why your getting the error message your getting.
If you don't know how to reference anything, then you need to spend more time learning VB because that is a basic concept.
Using Outlook is something to think about down the road.
John
I wouldnt think you'd have to be even a good programmer to attempt (successfully or otherwise) to write a virus. Hope this isn't the case.
It does sound suspiciously like a virus. Personally I don't know why someone would write one They have caused me so many headaches :( . But, on the upside of it I have gotten paid for takeing viruses out of computers. :)
Remove the pleasantries, and its the technical description of the loveletter virus.Quote:
Originally posted by Norkis
Hi,
Can anybody give me a code how to do this:
Catch all emails adressers from outlook.
Sent to all catched emails message with app.exe
Can anybody help me???
Please.
A tad suspicious, isn't it?
You definitely don't have to be much of a programmer to write a virus. I've seen the source code for the loveletter, and there's nothing there that even I couldn't do...
Really ??? I've never seen the code for a virus of any type. I always figured they were something the average idiot couldn't do.
Last time I post Outlook code. :)
John
The code for the loveletter virus is pretty much so everything posted on this page. It also makes copies of itself and what not, but thats basically it.
I think the hardest thing about writing viruses is probably finding a way to release them into the wild without having the FBI turn up on your doorstep a week later and terrify your mum.
... and no, that doesn't mean I've ever tried.
Hei you all!!!
I'm making not a virus.
I'm making the program for advertisement.
So anybody would help me?
From the original description, I've already posted 90% of what you need. The only other help anyone could give you is to actually write the entire program for you. That I won't do.
You need to study the code I posted and finish the rest of the program.
John
Norkis,
Just a suggestion .. I'd look for another way to advertise. Even if it isnt your intent to write a virus you could end up with something that causes the same effect.
Just some thoughts.
isn't your code supposed to be:?
VB Code:
ReDim Preserve aPAB(i - 1, 2)
your code doesn't work for me either
i sent a message to myself, and it never arrived
don't you need to specify some kind of server or something to send the mail to? i don't really know that much about this stuff, im trying to learn it myself.
it gets through the code just fine, but the message never arrives in my inbox
The Send Mail code requires that Outlook (2000 tested, should work with 98) be setup and working. If you can send with Outlook, this code should work fine.
The ns.Logon uses the Default profile, which for home use should be fine. This VB code uses the server listed in that profile/account.
Was your mail bounced back ???
Yes...the aPab() needs ReDim in front of it. Missed that somehow but checked all other code and it's all there.
John
ok, thanx
i only have outlook express working, whether this matters or not.
anyways, can this be used if the user doesn't have outlook and i just send them the MSOUTL9.OLB file?
and since they wouldn't have an account, would it be just as easy to set up my own account through code and then use that?
Sorry, that code only works with the full version of Outlook. From what I know, Outlook Express is a "limited" version that is a whole different ball game as far as controlling thru VB.
You can try but I doubt VERY much if sending anyone that file will help.
John
Thank you.
Your code works.
I have one more question:
This code only quere letters to outbox.
How with out any masage start sending these letters for outlook is conection is avaible?
And how to determe then sent is finished?
In Outlook, you need to go to Tool-Options and set Outlook to send mail immediatley if connected.
To actually "dial-up" automatically and send , you need to set the Internet Explorer settings to auto-dial and use the following function to dial-up the DEFAULT ISP providor you have on your system. To set IE, right click on the icon and select Properties. Then select the Connections tab. Make sure you have a default profile that works and 'Always dial my default connection' is selected. Make sure you call the following function BEFORE you do anything else with Outlook.
Private Declare Function InternetAutodialHangup Lib "wininet.dll" _
(ByVal dwReserved As Long) As Long
Private Declare Function InternetAutodial Lib "wininet.dll" _
(ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1 '<-- makes user hit enter on connect dialog
Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2 '<--- does it auto
'To automatically start dialling Internet connect
If InternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) Then
DoEvents
Else
MsgBox "Unable to connect to the Internet", vbCritical
Exit Sub
End If
' to dis-connect
If InternetAutodialHangup(0) Then
DoEvents
Else
MsgBox "Unable to dis-connect from the Internet", vbCritical
Exit Sub
End If
John
cool... no virus just spamQuote:
Originally posted by Norkis
Hei you all!!!
I'm making not a virus.
I'm making the program for advertisement.
So anybody would help me?