Send spreadsheet through email (NOT WITH OUTLOOK)

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I have searched this sight for a bit. I was wondering:
Is it possible to auto send an email without going through outlook? Say if I use Google Mail or Yahoo mail ONLY and wanted to send my spreadsheet in an email. Is this possible?

Thank You for any input, :biggrin: :biggrin:

Michael

ps. let me know, if it is not possible to. :eek:
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Using the .Sendmail method will automatically use your System Default Email Program... which is usually Outlook. I wouldn't even know how to change the system default to something else, but it must be possble... I am not sure if you can set the system default mail program to be a WebMail site, however. I would speculate not, but I may very well be wrong.

Otherwise, you could start a new instance of IE from VBA, then manipulat ethe aplication from there to create the message structure you are looking for...
 
Upvote 0
Otherwise, you could start a new instance of IE from VBA, then manipulat ethe aplication from there to create the message structure you are looking for...


I like this idea, What code could I use to get IE to work?

Michael :cool:
 
Upvote 0
I have never tried doing this myself... but I see 2 possibilities.

1) Use Sendkeys to manipulate the window: sendkeys tends to be problematic at best, and the sequence of keys required to perform certain activities will be volatile, as small changes to the site page design can invalidate the keystrokes needed to navigate that page. Here is one thread that discusses how to do this...

2) Use the Microsoft HTML Object Library to take diretc control of the IE window, automating it the same as you would automate a Native Excel instance: probably th emore robust method, but probably less intuitive to do... not a lot of documentation out there, but here is one source... I am sure there are others, but I didn't do an intensive search.
 
Upvote 0
So I was intrigued with your question, enough so that I played with some of the stuff in the article I posted above. I got this far, and cam to a grinding halt when I hit the ActiveX controls on the Compose page of the Yahoo Mail. I broke down and used a coupl eof SendKeys statements to get text into th ebody of th emessage... I didn't play with attachments at all. Then I absolutely could not in any way shape or form figure out how to actually send the message... so the window kinda peters out and waits for the user to hit Send and then clean up...

Code:
Sub WebMail()

    'reference: Microsoft Internet Controls
    'reference: Microsoft HTML Object Library

    Dim mIE As InternetExplorer
    Dim Item_link As HTMLLinkElement
    Dim Item_form As HTMLFormElement
        
    Set mIE = New InternetExplorer
    
    mIE.Visible = True
    
    mIE.Navigate "www.yahoo.com"

    Do Until mIE.readyState = READYSTATE_COMPLETE
    
    Loop
    
    For Each Item_link In mIE.Document.Links
    
        If Item_link.innerHTML = "My Mail" Then
        
            mIE.Navigate Item_link
            
            Exit For
            
        End If
    
    Next Item_link
    
    tmr = Timer()
        
    Do Until Timer() - tmr > 1
    
    Loop
    
    Do Until mIE.readyState = READYSTATE_COMPLETE
    
    Loop
    
    tmr = Timer()
        
    Do Until Timer() - tmr > 1
    
    Loop
    
    For Each Item_form In mIE.Document.forms
      
        For Each Item2 In Item_form.all
        
            a = "none"
        
            On Error Resume Next
            
            a = Item2.Name
            
            On Error GoTo 0
        
            If a = "login" Then
            
                Item2.Value = "USERID"
                
            ElseIf a = "passwd" Then
            
                Item2.Value = "PASSWORD"
                
            End If
        
        Next Item2
    
        Item_form.submit
    
    Next Item_form
    
    tmr = Timer()
        
    Do Until Timer() - tmr > 1
    
    Loop
    
    Do Until mIE.readyState = READYSTATE_COMPLETE
    
    Loop
    
    tmr = Timer()
        
    Do Until Timer() - tmr > 1
    
    Loop
    
    For Each Item_link In mIE.Document.Links
    
        If Item_link.innerHTML = "Compose" Then
        
            mIE.Navigate Item_link
            
            Exit For
            
        End If
    
    Next Item_link
    
    tmr = Timer()
        
    Do Until Timer() - tmr > 1
    
    Loop
    
    Do Until mIE.readyState = READYSTATE_COMPLETE
    
    Loop
    
    tmr = Timer()
        
    Do Until Timer() - tmr > 1
    
    Loop
    
    
    For Each Item_form In mIE.Document.forms
      
        For Each Item2 In Item_form.all
        
            a = "none"
        
            On Error Resume Next
            
            a = Item2.Name
            
            On Error GoTo 0
            
            Select Case a

                Case "To"
                    Item2.Value = "Email Address Here"
                Case "Cc"
'                    item2.Value = "Carbon Copy Here"
                Case "Bcc"
'                    item2.Value = "Blind Carbon Copy Here"
                Case "Subj"
                    Item2.Value = "Message Subject here"
                
            End Select
            
            cnt = cnt + 1
        
        Next Item2
    
'        Item.submit
    
    Next Item_form
    
    SendKeys "{TAB}", True

    SendKeys "{TAB}", True
    
    SendKeys "Body Here", True
    
'    'the submit method does't work... not sure how to send the mail once the message is composed
'    mIE.Document.forms("Compose").submit
'
'    'but this will sign you out and close the window
'    For Each Item_link In mIE.Document.Links
'
'        If Item_link.innerhtml = "Sign Out" Then
'
'            mIE.Navigate Item_link
'
'            Exit For
'
'        End If
'
'    Next Item_link
'
'    tmr = Timer()
'
'    Do Until Timer() - tmr > 1
'
'    Loop
'
'    Do Until mIE.readyState = READYSTATE_COMPLETE
'
'    Loop
'
'    tmr = Timer()
'
'    Do Until Timer() - tmr > 1
'
'    Loop
'
'
'    mIE.Quit
'
'    Set mIE = Nothing
End Sub

Good Luck.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top