Consulting

Results 1 to 13 of 13

Thread: Open emails from excel.

  1. #1

    Open emails from excel.

    in one cell name of site e.g yahoo.com is given, in second cell user name to login email account is given & in third name password is mentioned. IS it possible o directly open this side & loging to email account using name mentioned there!!
    A mighty flame followeth a tiny sparkle!!



  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    ExcelElliot, this reads as though you have collected names, log ins and passwords for e-mail accounts and is directly linked to this thread http://vbaexpress.com/forum/showthread.php?t=11132 if all the accounts are yours there are plenty of free sites or software out there to help you manage all your accounts automatically.

    Regards,
    Simon
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by excelliot
    in one cell name of site e.g yahoo.com is given, in second cell user name to login email account is given & in third name password is mentioned. IS it possible o directly open this side & loging to email account using name mentioned there!!
    Yes.

    Check out this discussion here.

    I've modified the code since then to look like this. Which I'm pretty sure I've tested with yahoo:
    [vba]Sub OpenMyGMAIL(MyLogin As String, MyPass As String, EmailSite As String)
    If MyLogin = "" Or MyPass = "" Or EmailSite = "" Then Exit Sub
    Dim ie As Object, oDoc As Object, oList As Object, oLists As Object
    Dim ieForm As Variant, form As Variant
    Dim WebPage As String
    Dim i As Integer

    Set ie = CreateObject("InternetExplorer.Application")

    WebPage = EmailSite

    ie.Visible = True

    ie.Navigate WebPage

    'Loop until IE pages is fully loaded
    Do Until ie.ReadyState = 4 'READYSTATE_COMPLETE
    Loop
    If ie.Document.Title = "Gmail" Then GoTo ExitHere
    Set oDoc = ie.Document
    Set ieForm = oDoc.forms(0)
    For Each form In ieForm
    Debug.Print form.outerHTML, i
    If LCase(form.ID) = "email" Or LCase(form.ID) = "username" Or LCase(form.ID) = "user" Then
    form.innertext = MyLogin
    ElseIf LCase(form.ID) = "passwd" Or LCase(form.ID) = "password" Then
    form.innertext = MyPass
    End If
    i = i + 1
    Next
    ie.Document.forms(0).Submit

    Do Until ie.ReadyState = 4
    Loop

    Debug.Print ie.Document.Title

    ExitHere:
    ie.Visible = True
    Set ie = Nothing
    End Sub[/vba]

    For your purpose you could use like this:
    [vba]Public Sub Test()
    Dim strUserName As String, strPassword As String, strEmailSite As String
    strUserName = ActiveSheet.Range("A1").Text
    strPassword = ActiveSheet.Range("A2").Text
    strEmailSite = ActiveSheet.Range("A3").Text
    Call OpenMyGMAIL(strUserName, strPassword, strEmailSite)
    End Sub[/vba]

    With A1=Username, A2=Password, A3=EmailSite

    Hope this helps




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  4. #4
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    With some little changes it worked fine for me. Thank you Joseph for the revised code.

    Charlize

  5. #5
    VBAX Regular xls's Avatar
    Joined
    Aug 2005
    Posts
    76
    Location

    Arrow

    Just Try this This will Serve your requirements..

    [vba]
    Public CheckMailz Test()
    Dim strUserName As String, strPassword As String, strEmailSite As String
    strEmailSite = ActiveSheet.Range("A3").Text
    strUserName = ActiveSheet.Range("B3").Text
    strPassword = ActiveSheet.Range("C3").Text
    Call OpenMyGMAIL(strUserName, strPassword, strEmailSite)
    End Sub

    Sub OpenMyGMAIL(MyLogin As String, MyPass As String, EmailSite As String)
    Dim ie As Object, oDoc As Object
    Dim ieForm As Variant
    Dim WebPage As String

    Set ie = CreateObject("InternetExplorer.Application")

    WebPage = ActiveSheet.Range("A3").Text
    ie.Visible = True
    ie.navigate WebPage

    'Loop until IE pages is fully loaded

    Do Until ie.ReadyState = 4 'READYSTATE_COMPLETE
    Loop

    Set oDoc = ie.Document
    Set ieForm = oDoc.forms(0)

    ieForm(6).innerText = ActiveSheet.Range("B3").Text
    ieForm(7).innerText = ActiveSheet.Range("C3").Text
    ie.Document.forms(0).Submit


    End Sub[/vba]

    All D Best.

  6. #6
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    [VBA]ieForm(22).innerText = ActiveSheet.Range("B3").Text
    ieForm(23).innerText = ActiveSheet.Range("C3").Text [/VBA]

  7. #7
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by Charlize
    With some little changes it worked fine for me. Thank you Joseph for the revised code.

    Charlize
    No problem

    Hey guys, I'm curious to know that the ID text was of what you changed in my code:

    ieForm(22).ID
    ieForm(23).ID

    ieForm(6).ID
    ieForm(7).ID

    If you could, please. I'd like to refine the code some more




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  8. #8
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    For Yahoo it was username and passwd (according to me). On the 22nd and 23td item the loop was executed (value of i). For the use of both Gmail and Yahoo I removed the line [VBA]If ie.Document.Title = "Gmail" Then Goto ExitHere[/VBA]because it has no use (it's my humble opinion) when checking for multiple accounts. Also removed to exithere: line

    Charlize

  9. #9
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by Charlize
    [vba]If ie.Document.Title = "Gmail" Then Goto ExitHere[/vba]because it has no use (it's my humble opinion) when checking for multiple accounts.
    Charlize,

    Yes, you are absolutely correct. I was using that line to check if I had already logged in. Thanks for bringing that up because I could just use "On Error Goto ExitHere" like:
    [vba]Sub OpenMyGMAIL(MyLogin As String, MyPass As String, EmailSite As String)
    If MyLogin = "" Or MyPass = "" Or EmailSite = "" Then Exit Sub
    Dim ie As Object, oDoc As Object, oList As Object, oLists As Object
    Dim ieForm As Variant, form As Variant
    Dim WebPage As String
    Dim i As Integer

    On Error GoTo ExitHere

    Set ie = CreateObject("InternetExplorer.Application")

    WebPage = EmailSite

    ie.Visible = True

    ie.Navigate WebPage

    'Loop until IE pages is fully loaded
    Do Until ie.ReadyState = 4 'READYSTATE_COMPLETE
    Loop

    Set oDoc = ie.Document
    Set ieForm = oDoc.forms(0)
    For Each form In ieForm
    Debug.Print form.outerHTML, i
    If LCase(form.ID) = "email" Or LCase(form.ID) = "username" Or LCase(form.ID) = "user" Then
    form.innertext = MyLogin
    ElseIf LCase(form.ID) = "passwd" Or LCase(form.ID) = "password" Then
    form.innertext = MyPass
    End If
    i = i + 1
    Next
    ie.Document.forms(0).Submit

    Do Until ie.ReadyState = 4
    Loop

    Debug.Print ie.Document.Title

    ExitHere:
    ie.Visible = True
    Set ie = Nothing
    End Sub[/vba]

    And I'm assuming you didn't have to explicitly call out the form numbers using this code? Or you just provided it to show which form numbers you ended up with in comparison to xls' form numbers?

    And if you and xls were both calling out form numbers using the same site (i.e. yahoo), then I would suggest not to do that. It just doesn't seem dynamic enough to me.




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  10. #10
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Just tested the loop again and for Gmail it is indeed 6 and 7. For myself I use the loop because it's handy that with one routine you could check multiple accounts for new items. One problem that could arise are the names that are given to the formvariables. Maybe use external file to read possible names of variables per two

    name
    password
    login
    passwd
    inlog
    logpass
    inlogid
    checkpass

    ...

    Charlize

    ps. Or just looking for the most used names in those forms and hoping that most sitebuilders would use those variables.

  11. #11
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Quote Originally Posted by Charlize
    ...Maybe use external file to read possible names of variables per two...
    Great idea Charlize.

    Haven't made it yet, but I'm thinking about making 2 text files that will list all the form IDs that you mentioned (one file for userID and another for password), with a delimeter of a carriage return. Then the procedure could read the text files for the IDs and maybe store them into arrays, then use them in the loop of the forms.

    At the same time while this is happening, we can store the web page's form IDs into another array. And if none of the form IDs we listed are found, a message box could show up stating that it couldn't recognize the form IDs. The user will be given the option to add form IDs to the text files from the form IDs that were in the page itself. The addition of the form IDs to the text files can be done numeris ways (userform, input boxes, etc).

    Like I said, haven't made anything yet (gotta study for a test), but just putting the idea out there.



    Is there a standard for web page development? Like standard form ID names?




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  12. #12
    VBAX Regular xls's Avatar
    Joined
    Aug 2005
    Posts
    76
    Location
    Quote Originally Posted by malik641
    Great idea Charlize.
    Is there a standard for web page development? Like standard form ID names?
    Even i wondered same, if there would have something like that, then no prob wud hav arose.

  13. #13
    VBAX Regular xls's Avatar
    Joined
    Aug 2005
    Posts
    76
    Location
    I read this thread,

    http://www.vbaexpress.com/forum/show...ht=Got+mail%3F

    Is there anyway to get data, without opening web page???
    Winners dont do different things, they do things differently.

Posting Permissions

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