Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Create a form
- Below method uses 2 textBoxes from form
- ```vba
- Private Sub sendButton_Click()
- Dim text As String
- Dim i As Integer
- Dim entry As String
- Dim entries() As String
- Dim objOutlook As Outlook.Application
- Dim objOutlookMsg As Outlook.MailItem
- Dim objOutlookRecip As Outlook.Recipient
- text = "[prevday]" & vbNewLine
- entries = Split(UserForm1.prevText.Value, vbNewLine)
- For i = LBound(entries) To UBound(entries)
- text = text & "XXX: " & entries(i) & vbNewLine
- Next
- text = text & vbNewLine & "[today]" & vbNewLine
- entries = Split(UserForm1.todayText.Value, vbNewLine)
- For i = LBound(entries) To UBound(entries)
- text = text & "YYY: " & entries(i) & vbNewLine
- Next
- ' Create the Outlook session.
- Set objOutlook = CreateObject("Outlook.Application")
- ' Create the message.
- Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
- Set objOutlookRecip = objOutlookMsg.Recipients.Add("some@mail.example.org")
- objOutlookRecip.Type = olTo
- objOutlookMsg.Subject = "[SubjectTag] " & Format(Date, "yyyymmdd")
- objOutlookMsg.Body = text
- objOutlookMsg.BodyFormat = olFormatPlain
- objOutlookMsg.Send
- ` MsgBox ("Send")
- ` clean
- UserForm1.todayText.Value = ""
- UserForm1.prevText.Value = ""
- UserForm1.Hide
- End Sub
- ```
- ### create public method in module
- ```vba
- Public Sub ShowMyForm()
- UserForm1.Show
- End Sub
- ```
- ### add Button to ToolBar
- ShowMyForm should be in Marcors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement