Results 1 to 32 of 32

Thread: Outlook...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    Outlook...

    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.

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    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.

  3. #3
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    '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

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    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.

  5. #5
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    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.

  7. #7
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    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?

  9. #9
    Junior Member
    Join Date
    Jul 2001
    Location
    Dublin
    Posts
    27

    might help ?

    confused:



    Perhaps, er, , Outlook object library might need to be referenced ?...confused:

  10. #10
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Norkis, are you trying to write a virus ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  11. #11
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Nice one Jamie, I had the same thought....
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  12. #12
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Though it could in theory be totally legit.
    Doubt it tho
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  13. #13
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    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*
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  14. #14
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  15. #15
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    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.

  16. #16
    Member
    Join Date
    Dec 2000
    Posts
    36
    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.
    Real knowledge is to know the extent of ones ignorance.

  17. #17
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Outlook...

    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.
    Remove the pleasantries, and its the technical description of the loveletter virus.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  18. #18
    Fanatic Member InvisibleDuncan's Avatar
    Join Date
    May 2001
    Location
    Eating jam.
    Posts
    819
    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...
    Indecisiveness is the key to flexibility.

    www.mangojacks.com

  19. #19
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  20. #20
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    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.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  21. #21
    Fanatic Member InvisibleDuncan's Avatar
    Join Date
    May 2001
    Location
    Eating jam.
    Posts
    819
    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.
    Indecisiveness is the key to flexibility.

    www.mangojacks.com

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    Hei you all!!!
    I'm making not a virus.
    I'm making the program for advertisement.

    So anybody would help me?

  23. #23
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  24. #24
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    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.

  25. #25
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    isn't your code supposed to be:?
    VB Code:
    1. ReDim Preserve aPAB(i - 1, 2)
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  26. #26
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    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 human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  27. #27
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  28. #28
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    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?
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  29. #29
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    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?

  31. #31
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    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

  32. #32
    Frenzied Member Skitchen8's Avatar
    Join Date
    Feb 2001
    Location
    Binghamotn, NY
    Posts
    1,943
    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?
    cool... no virus just spam
    Government is another way to say better…than…you.
    It’s like ice but no pick, a murder charge that won’t stick,
    it’s like a whole other world where you can smell the food,
    but you can’t touch the silverware.
    Huh, what luck. Fascism you can vote for.
    Humph, isn’t that sweet?
    And we’re all gonna die some day, because that’s the American way
    -Stone Sour

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width