LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active X Controls Tabbing from Form Field 2 Form Field Tfrup12 Excel Discussion (Misc queries) 0 February 19th 08 08:15 PM
Web Qery Based On Form Field Input netbrink Excel Programming 3 April 15th 06 08:25 PM
Move a Column of 500 Email Addresses into BCC Field of an Email Mark Excel Worksheet Functions 9 July 27th 05 05:07 AM
Email an Excel form input using VBA Jaime[_3_] Excel Programming 6 January 26th 04 06:12 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 12:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"