I'm trying to make a program where all the user has to enter is the e-mail address to send the e-mail, the subject, and the message and it will send the e-mail with no problem.
If you don't mind the User Pressing the Send Button you could launch the Default Mail Client using the ShellExecute API passing the Email, Subject and Message in the Command Line.
Otherwise you could use the Winsock Control to Access a Mail Server Directly, eg.
For this example you'll need a Winsock Control, Command Button and several Textboxes..
Code:
Private Sub cmdSend_Click()
Caption = "Sending Message.."
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Connect "Some.MailServer.com", 25
End Sub
Private Sub Winsock1_Connect()
Winsock1.SendData "HELO " & Winsock1.LocalIP & vbCrLf & _
"MAIL FROM: <[email protected]>" & vbCrLf & _
"RCPT TO: <" & txtTo & ">" & vbCrLf & _
"DATA" & vbCrLf & _
"TO: " & txtTo & vbCrLf & _
"FROM: <[email protected]>" & vbCrLf & _
"SUBJECT: " & txtSubject & vbCrLf & _
txtMsg & vbCrLf & "." & vbCrLf & _
"QUIT" & vbCrLf
End Sub
Private Sub Winsock1_SendComplete()
Caption = "Send Complete."
End Sub
The subprogram below utilizes a MAPI Session and MAPIMessage control from the MS MAPI 6.0 controls to send a message. It automatically opens the default email client (in the background) and sends a message using the specified information. It works well, I have used it in VB and in MS Access apps.
Private Sub SendEmail()
MAPISession1.SignOn
MAPIMessages1.SessionID = Me.MAPISession1.SessionID
MAPIMessages1.Compose
MAPIMessages1.MsgSubject = "Hey Hey"
MAPIMessages1.MsgNoteText = "This is the body of my email"
MAPIMessages1.RecipAddress = "[email protected]"
MAPIMessages1.Send
MAPISession1.SignOff
End Sub
Your code doesn't work for me: when it reaches the line "MAPIMessages1.Send" I get error 32002 "error not specified". Is there anything wrong in the code? Am I missing something? Please, help! I need to be able to send e-mails automatically!
I think the above code is woderfull for my app however could someone please explain why my e-mail is not getting delivered. This Is the message I'm getting.
No transport provider was available for delivery to this recipient.
Also, what is ment by setting send = true?
Is that my line of code? send = true What does it do?
While I am sure your post is helpful to someone please check the date of the last post before replying to a thread. This thread had been dead for 11 years before you replied to it.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
While I am sure your post is helpful to someone please check the date of the last post before replying to a thread. This thread had been dead for 11 years before you replied to it.
I used the settings you suggested in the earlier post, and attempted to enable both POP and SMTP in my g mail account, but I was a little unsure how to do that. I think I got the POP enabled, but didn't see where to enable SMTP. Can you point me to where that is done more specifically? Thanks again!
I am using your cdo code, and calling is using parameters from text boxes. I have stepped through it to verify that I like the values that I'm feeding into it.