vba send userform in readable format

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
I have a userform which on completion sends the relevant data to the relevant cells in excel. However I also need to send the form inputs to a person via email, in a readable format, and have no idea how to do this.

Do I need to set the layout in a word document, or can this be done in excel?

Any help would be appreciated, as would a pointing in the right direction, or to any helpful links.

Thanks
 

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
I thought perhaps that because it was a company email, there might have been further security measures that were preventing this from working, so I set-up my own personal gmail account. However I still get exactly the same error message :(
 
Upvote 0
You have a firewall / antivirus that is blocking the email. It doesnt let you send it to protect from bulk mail. Deactivate the antivirus and it will work. I have a similar problema and I'm hopping someone can help me. The situation is the same, but since I work in a company and cant deactivate mcafee I was wondering if somebody had a code to go around the antivirus. If nobody can help me with that (almos impossible i guess) I was hopping someone could help me with another problem I'm having. I managed the cdo code to send an email in a excel file I have. Another excel file has a userform. I want the cdo to send the userform. Can someone help me put both codes together.

File one with cdo code:

Private Sub CommandButton3_Click()


Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "my@gmail.com"
objMessage.To = "my@gmail.com" ' sent to myself, not at gmail
objMessage.TextBody = "This is some sample message text."

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2


'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1


'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "my"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"


'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
objMessage.Configuration.Fields.Update




objMessage.Send
Set objMessage = Nothing
End Sub


Here is the userform code:

Private Sub Enviar_Click()
Dim OutApp As Object
Dim OutMail As Object


Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)


With UserForm1
cbx1 = .CheckBox1.Caption
cbx2 = .CheckBox2.Caption
txtbox1 = .TextBox1
txtbox2 = .TextBox2
End With


On Error Resume Next
With OutMail
.To = "my@ngel.pt"
.CC = ""
.BCC = ""
If cbx1.Value = True Then
.Subject = cbx1
End If
If cbx1.Value = False Then
.Subject = cbx2
End If
If cbx2.Value = True Then
.Subject = cbx2
End If
If CheckBox1.Value = False And CheckBox2.Value = False Then
Enable = True
MsgBox "You must check one of the boxes"


End If
.HTMLBody = "SL ERROR - " & vbcrf & txtbox1 & vbcrf & vbcrf & txtbox2
.Send
End With
On Error GoTo 0


Set OutMail = Nothing
Set OutApp = Nothing


Unload UserForm1


End Sub



CAN SOMEBODY HELP ME PLEASE
 
Upvote 0
Mine was failing due to the following line objEmail.Configuration.Fields.Item("Error") = "smtp.gmail.com"

I had to change it to reference the private smtp server that the company uses.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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