Hello everyone
i have developed to send a email via outlook the code seems to be fine ,but i just have small problem , i have to print numeric and alpha numeric value from the cell but my code doesn't allow to do that, it shows error. the code is working fine when i use alphabets in the cell but when is use numeric or alpha-numeric value then it doesn't work please help me out in this. Below i have mentioned my code , i need to print numeric value from "str" and alpha numeric from "funid"
many thanks in advance
Private Sub CommandButton1_Click()
Dim str As String
Dim we As Worksheet
Set we = Worksheets("sam")
Range("A2").Select
While Not ActiveCell = ""
Mail_To = ActiveCell.Offset(0, 0)
Mail_Subject = "testing"
Mail_Voting = ActiveCell.Offset(0, 4)
str = ActiveCell.Offset(0, 3)
funid = ActiveCell.Offset(0, 2)
Set myolapp = CreateObject("Outlook.Application")
Set myitem = myolapp.CreateItem(olMailItem)
With myitem
.VotingOptions = Mail_Voting
.To = Mail_To
.Body = "Hello" + " " + str + " " + funid + " " + vbNewLine + we.Cells(1, 1)
.Subject = "confirmation mail"
.display
End With
ActiveCell.Offset(1, 0).Select
Wend
End Sub
i have developed to send a email via outlook the code seems to be fine ,but i just have small problem , i have to print numeric and alpha numeric value from the cell but my code doesn't allow to do that, it shows error. the code is working fine when i use alphabets in the cell but when is use numeric or alpha-numeric value then it doesn't work please help me out in this. Below i have mentioned my code , i need to print numeric value from "str" and alpha numeric from "funid"
many thanks in advance
Private Sub CommandButton1_Click()
Dim str As String
Dim we As Worksheet
Set we = Worksheets("sam")
Range("A2").Select
While Not ActiveCell = ""
Mail_To = ActiveCell.Offset(0, 0)
Mail_Subject = "testing"
Mail_Voting = ActiveCell.Offset(0, 4)
str = ActiveCell.Offset(0, 3)
funid = ActiveCell.Offset(0, 2)
Set myolapp = CreateObject("Outlook.Application")
Set myitem = myolapp.CreateItem(olMailItem)
With myitem
.VotingOptions = Mail_Voting
.To = Mail_To
.Body = "Hello" + " " + str + " " + funid + " " + vbNewLine + we.Cells(1, 1)
.Subject = "confirmation mail"
.display
End With
ActiveCell.Offset(1, 0).Select
Wend
End Sub