ExcelTheCell
Board Regular
- Joined
- Nov 14, 2010
- Messages
- 158
Code:
IE.Navigate "[URL]https://mail.google.com/mail/u/0/#inbox[/URL]"
Any easy way...
Last edited:
IE.Navigate "[URL]https://mail.google.com/mail/u/0/#inbox[/URL]"
the "sendUsing" configuration value is invalid
Function AddIEFRAME()
'Add referance from library named Microsoft internet contol
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\ieframe.dll")
1:
End Function
Function AddMsHtml()
'Add referance from library named Microsoft HTML object library
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\MsHtml.tlb")
1:
End Function
Function AddCDOWIN()
'Add referance from library named Microsoft CDO for WIn 2000 library
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\cdosys.dll")
1:
End Function
Sub CDO_Mail_Small_Text()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim IE As InternetExplorer
Call AddIEFRAME
Call AddMsHtml
Call AddCDOWIN
Set IE = New InternetExplorer
IE.Navigate "[URL]https://mail.google.com/mail/u/0/#compose[/URL]"
IE.Visible = True
' Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "[EMAIL="ron@debruin.nl"]ron@debruin.nl[/EMAIL]"
.CC = ""
.BCC = ""
.From = """Ron"" <[EMAIL="ron@something.nl"]ron@something.nl[/EMAIL]>"
.Subject = "New figures"
.TextBody = strbody
.Send
End With
End Sub
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Full GMail mail address"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "GMail password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
Sub CDO_Mail_Small_Text()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
' add reference
Call AddIEFRAME
Call AddMsHtml
Call AddCDOWIN
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("[URL]http://schemas.microsoft.com/cdo/con...ion/smtpusessl[/URL]") = True
.Item("[URL]http://schemas.microsoft.com/cdo/con...tpauthenticate[/URL]") = 1
.Item("[URL]http://schemas.microsoft.com/cdo/con...n/sendusername[/URL]") = "[EMAIL="mrexceltest@gmail.com"]mrexceltest@gmail.com[/EMAIL]"
.Item("[URL]http://schemas.microsoft.com/cdo/con...n/sendpassword[/URL]") = "mrexceltest321"
.Item("[URL]http://schemas.microsoft.com/cdo/con...ion/smtpserver[/URL]") = "smtp.gmail.com"
.Item("[URL]http://schemas.microsoft.com/cdo/con...tion/sendusing[/URL]") = 2
.Item("[URL]http://schemas.microsoft.com/cdo/con...smtpserverport[/URL]") = 25
.Update
End With
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "[EMAIL="mrexceltest@gmail.com"]mrexceltest@gmail.com[/EMAIL]"
.CC = ""
.BCC = ""
.From = "[EMAIL="mrexceltest@gmail.comm"]mrexceltest@gmail.comm[/EMAIL]"
.Subject = "New figures"
.TextBody = strbody
.Send
End With
End Sub
'-------------------------------------- ACTIVATE REFERECES ---------------------------------------
Function AddIEFRAME()
'Add referance from library named Microsoft internet contol
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\ieframe.dll")
1:
End Function
Function AddMsHtml()
'Add referance from library named Microsoft HTML object library
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\MsHtml.tlb")
1:
End Function
Function AddCDOWIN()
'Add referance from library named Microsoft CDO for WIn 2000 library
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\cdosys.dll")
1:
End Function
Option Explicit
'If you have a GMail account then you can try this example to use the GMail smtp server
'The example will send a small text message
'You must change four code lines before you can test the code
'.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusername[/URL]") = "Full GMail mail address"
'.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendpassword[/URL]") = "GMail password"
'Use your own mail address to test the code in this line
'.To = "Mail address receiver"
'Change YourName to the From name you want to use
'.From = """YourName"" <[EMAIL="Reply@something.nl"]Reply@something.nl[/EMAIL]>"
'If you get this error : The transport failed to connect to the server
'then try to change the SMTP port from 25 to 465
Sub CDO_Mail_Small_Text_2()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
' add reference
Call AddIEFRAME
Call AddMsHtml
Call AddCDOWIN
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpusessl[/URL]") = True
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate[/URL]") = 1
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusername[/URL]") = "[EMAIL="mrexceltest@gmail.com"]mrexceltest@gmail.com[/EMAIL]"
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendpassword[/URL]") = "mrexceltest321"
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserver[/URL]") = "smtp.gmail.com"
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusing[/URL]") = 2
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserverport[/URL]") = 465
.Update
End With
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "[EMAIL="mrexceltest@gmail.com"]mrexceltest@gmail.com[/EMAIL]"
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail example
' It will use your Gmail address automatic. But you can add this line
' to change the reply address .ReplyTo = "[EMAIL="Reply@something.nl"]Reply@something.nl[/EMAIL]"
.From = "[EMAIL="mrexceltest@gmail.com"]mrexceltest@gmail.com[/EMAIL]"
.Subject = "Important message"
.TextBody = strbody
.Send
End With
End Sub
'-------------------------------------- ACTIVATE REFERECES ---------------------------------------
Function AddIEFRAME()
'Add referance from library named Microsoft internet contol
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\ieframe.dll")
1:
End Function
Function AddMsHtml()
'Add referance from library named Microsoft HTML object library
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\MsHtml.tlb")
1:
End Function
Function AddCDOWIN()
'Add referance from library named Microsoft CDO for WIn 2000 library
On Error GoTo 1
ThisWorkbook.VBProject.References.AddFromFile ("C:\WINDOWS\System32\cdosys.dll")
1:
End Function
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mrexceltest@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mrexceltest321"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Update
End With