Hi all,
Just following up on an earlier post with a different question. I have managed to get excel to send an e-mail via gmail thanks to some great advice from Redbeard. I think a new post may now be more appropriate.
My other questions associated with this process are:
1. Is it possible to 'Display' instead of 'Send' a Gmail?
2. Is it possible to attach a file with vba code to open a search on my pc then click and select a file to attach?
3. To select and paste e-mail addresses from a list that meet certain criteria (the criteria might be a 1 or 0 in an adjacent column to signify selection of qualifying recipients) and place them in the bcc field?
4. Is it possible to use a vba reference to get information or a different message based on criteria into the vba below?
e.g. message 1 might say 'Please contact us', message 2 'You are already registered'. The users will be filling in a form to register, and their responses will determine the message to use.
Sorry its 4 questions, if anyone wants to just answer one of them that's fine.
Here's the code I currently have (below this message).
Thanks for any help or suggestions,
Regards,
Vern
Just following up on an earlier post with a different question. I have managed to get excel to send an e-mail via gmail thanks to some great advice from Redbeard. I think a new post may now be more appropriate.
My other questions associated with this process are:
1. Is it possible to 'Display' instead of 'Send' a Gmail?
2. Is it possible to attach a file with vba code to open a search on my pc then click and select a file to attach?
3. To select and paste e-mail addresses from a list that meet certain criteria (the criteria might be a 1 or 0 in an adjacent column to signify selection of qualifying recipients) and place them in the bcc field?
4. Is it possible to use a vba reference to get information or a different message based on criteria into the vba below?
e.g. message 1 might say 'Please contact us', message 2 'You are already registered'. The users will be filling in a form to register, and their responses will determine the message to use.
Sorry its 4 questions, if anyone wants to just answer one of them that's fine.
Here's the code I currently have (below this message).
Thanks for any help or suggestions,
Regards,
Vern
Code:
Private Sub cmdSendEmail_Click()
Dim Mail As New message
Dim Config As Configuration
Set Config = Mail.Configuration
'Set Mail = server.CreateObject("CDO.Message")
Config(cdoSendUsingMethod) = cdoSendUsingPort
Config(cdoSMTPServer) = "smtp.gmail.com"
Config(cdoSMTPAuthenticate) = 25
Config(cdoSMTPAuthenticate) = cdoBasic
Config(cdoSMTPUseSSL) = True
Config(cdoSendUserName) = "myusername"
Config(cdoSendPassword) = "mypassword"
Config.Fields.Update
Mail.To = "recipient e-mail"
Mail.From = Config(cdoSendUserName)
Mail.Subject = "Email Subject"
Mail.HTMLBody = "[B]EmailBody here[/B]"
On Error Resume Next
Mail.Send ' Tried Draft, Open, Display, all failed
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "There was an error"
Exit Sub
End If
MsgBox "Your e-mail has been sent!", vbInformation, "Sent"
End Sub