Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Input field from VBA form in an email
Hello,
I tried to send some data from a userform I'd created and my code does transmit the data into my worksheet but not in the email. Anybody can help me out ? Thanks Here is my code: Private Sub CommandButton1_Click() 'Clear the controls 'Clear the CONTACTNAME ContactName.Value = "" 'Clear the PHONENUMBER PhoneNumber.Value = "" 'Clear the ACCOUNTID AccountID.Value = "" 'Clear the POSTINGID PostingID.Value = "" 'Clear the FAR FAR.Value = "" 'Clear the MESSAGE Message.Value = "" 'Clear the REPNEEDED RepNeeded.Value = "" 'Clear the FORWARDTO ForwardTo.Value = "" 'Bring the cursor to the beginning of the form VoiceMailSource.SetFocus End Sub Private Sub FAR_DropButtonClick() FAR.RowSource = "FAR!B2:B26" End Sub Private Sub ForwardTo_DropButtonClick() ForwardTo.RowSource = "ForwardTo!C2:C11" End Sub Private Sub Message_Change() End Sub Private Sub UserForm_Click() End Sub Private Sub VoiceMailSource_DropButtonClick() VoiceMailSource.RowSource = "VoiceMailSource!B2:B6" End Sub Private Sub RepNeeded_DropButtonClick() RepNeeded.RowSource = "RepNeeded!C2:C15" End Sub Private Sub CommandButton2_Click() Dim NextRow As Long 'Make sure VoiceMailData is active Sheets("VoiceMailData").Activate 'Determine the next empty row NextRow = Application.WorksheetFunction. _ CountA(Range("A:A")) + 1 'Transfer the ID Cells(NextRow, 1) = AutoNumber() 'Transfer the USER Cells(NextRow, 2) = USER() 'Transfer the DATE Cells(NextRow, 3).Value = Now() 'Transfer the SOURCE Cells(NextRow, 4).Value = VoiceMailSource.Value 'Transfer the CONTACTNAME Cells(NextRow, 5).Value = ContactName.Value 'Transfer the PHONENUMBER Cells(NextRow, 6).Value = PhoneNumber.Value 'Transfer the ACCOUNTID Cells(NextRow, 7).Value = AccountID.Value 'Transfer the POSTINGID Cells(NextRow, 8).Value = PostingID.Value 'Transfer the FAR Cells(NextRow, 9).Value = FAR.Value 'Transfer the MESSAGE Cells(NextRow, 10).Value = Message.Value 'Transfer the REPNEEDED Cells(NextRow, 11).Value = RepNeeded.Value 'Transfer the FORWARDTO Cells(NextRow, 11).Value = ForwardTo.Value 'Clear the controls for the next entry 'Clear the CONTACTNAME ContactName.Value = "" 'Clear the PHONENUMBER PhoneNumber.Value = "" 'Clear the ACCOUNTID AccountID.Value = "" 'Clear the POSTINGID PostingID.Value = "" 'Clear the FAR FAR.Value = "" 'Clear the MESSAGE Message.Value = "" 'Clear the REPNEEDED RepNeeded.Value = "" 'Clear the FORWARDTO ForwardTo.Value = "" 'Bring the cursor to the beginning of the form VoiceMailSource.SetFocus 'Message Box informing that the data has been posted MsgBox "Your data has been posted. Thank You" 'Send the email sendmail End Sub Public Function sendmail() On Error GoTo ende esubject = "URGENT - Voicemail from" & " " & ContactName.Value & " " & AccountID.Value sendto = " ccto = " ebody = "Please find the voicemail information left by" & " " & ContactName.Value & vbCrLf & "on " & Now() & "." & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "To=" & RepNeeded.Value & vbCrLf & "Account ID=" & AccountID.Value & " " & " " & " " & " " & "Posting ID=" & PostingID.Value & vbCrLf & "Reason for call=" & FAR.Value & vbCrLf & vbCrLf & "Message=" & Message.Value & vbCrLf & vbCrLf & "ContactName=" & ContactName.Value & vbCrLf & "Call Back #=" & PhoneNumber.Value & vbCrLf & vbCrLf & vbCrLf & "Thank You" & vbCrLf & USER() Set app = CreateObject("Outlook.Application") Set itm = app.createitem(0) With itm ..Subject = esubject ..to = sendto ..cc = ccto ..body = ebody ..display Application.Wait (Now + TimeValue("0:00:01")) Application.SendKeys "%S" End With Set app = Nothing Set itm = Nothing ende: End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Active X Controls Tabbing from Form Field 2 Form Field | Excel Discussion (Misc queries) | |||
Web Qery Based On Form Field Input | Excel Programming | |||
Move a Column of 500 Email Addresses into BCC Field of an Email | Excel Worksheet Functions | |||
Email an Excel form input using VBA | Excel Programming | |||
CODE to select range based on User Input or Value of Input Field | Excel Programming |