Hi everyone!
I am trying to connect excel to gmail via VBA. I did it and macro successfully sends the email. BUT!
I want to see and be able to edit the email with attachment if necessary! I know that you cannot display CDO.message but maybe there is a way around/past that ???
Here is my code:
Sub sendemail()
Dim mymail As CDO.message
Set mymail = New CDO.message
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "*******@gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
mymail.Configuration.Fields.Update
With mymail
.Subject = "Test Email from El"
.From = "******@gmail.com"
.To = ""
.CC = ""
.BCC = ""
.TextBody = "Goor morning!"
.addAttachments "c:\...."
.Send 'do not want to send, how to display instead?
End With
On Error Resume Next
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "there was an error"
Exit Sub
End If
MsgBox ("mail has been sent")
Set mymail = Nothing
End Sub
I am trying to connect excel to gmail via VBA. I did it and macro successfully sends the email. BUT!
I want to see and be able to edit the email with attachment if necessary! I know that you cannot display CDO.message but maybe there is a way around/past that ???
Here is my code:
Sub sendemail()
Dim mymail As CDO.message
Set mymail = New CDO.message
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "*******@gmail.com"
mymail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
mymail.Configuration.Fields.Update
With mymail
.Subject = "Test Email from El"
.From = "******@gmail.com"
.To = ""
.CC = ""
.BCC = ""
.TextBody = "Goor morning!"
.addAttachments "c:\...."
.Send 'do not want to send, how to display instead?
End With
On Error Resume Next
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "there was an error"
Exit Sub
End If
MsgBox ("mail has been sent")
Set mymail = Nothing
End Sub