this code behin :
Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity
Imports System.IO
Imports System.Net.Mail
Imports DotNetNuke.UI.Utilities
Namespace EOA.Modules.Resume
Partial Class ViewResume
Inherits Entities.Modules.PortalModuleBase
Protected picurl As System.Web.UI.HtmlControls.HtmlInputFile
Dim resumeCtrlr As New ResumeController
Private SelectedFileName As String = " "
Public Sub SendMailToAddress(ByVal strReciever As String, ByVal strSubject As String, ByVal strBody As String)
Try
If strReciever.Length <> 0 Then
Dim EMailer As System.Web.Mail.MailMessage
EMailer = New System.Web.Mail.MailMessage()
EMailer.From = "job@indonya.com"
EMailer.Body = strBody
'EMailer.BodyEncoding = System.Text.UTF8Encoding.UTF8;
EMailer.BodyFormat = System.Web.Mail.MailFormat.Html
EMailer.Subject = strSubject
EMailer.[To] = strReciever
System.Web.Mail.SmtpMail.Send(EMailer)
End If
Catch ex As Exception
End Try
End Sub
Private Function GetUniqFileName(ByVal ext As String) As String
Dim validExt As String = "..doc,.docx,.pdf,.jpg,.jpeg,.tif,.bmp,.rtf,.txt,.png"
If validExt.IndexOf(ext.ToLower) > 0 Then
Dim dt As New DateTime()
dt = DateTime.Now
Dim filename As String = Convert.ToString(dt.Year, 10) + Convert.ToString(dt.Month, 10) + Convert.ToString(dt.Day, 10) + Convert.ToString(dt.Hour, 10) + Convert.ToString(dt.Minute, 10) + Convert.ToString(dt.Second, 10) + Convert.ToString(dt.Millisecond, 10)
'filename=Convert.ToString(Convert.ToInt32(dt.ToString(),10),10);
filename = filename + ext
'idNews.Text=filename ;
SelectedFileName = filename
Return filename
End If
Return ""
End Function
Private Sub FtpImage()
Dim ctrl As Control = FormView1.FindControl("picurl")
picurl = DirectCast(ctrl, HtmlInputFile)
If picurl.PostedFile IsNot Nothing Then
Dim myFile As HttpPostedFile = picurl.PostedFile
Dim nFileLen As Integer = myFile.ContentLength
If nFileLen > 0 Then
Dim myData As Byte() = New Byte(nFileLen - 1) {}
myFile.InputStream.Read(myData, 0, nFileLen)
Dim strFilename As String = GetUniqFileName(Path.GetExtension(myFile.FileName))
If String.IsNullOrEmpty(strFilename) Then
AddItemButton.Text = "فایل رزومه شما غیر مجاز می باشد.نوع فایل رزومه فقط می تواند فایل میکروسافت ورد ، آکروبات یا تصویر باشد"
AddItemButton.Text = AddItemButton.Text + " *.doc,*.docx,*.pdf,*.jpg,*.jpeg,*.tif,*.bmp,*.rtf,*.txt,*.png"
'Throw New Exception("Invalid File Type...Only picture ,word doc, and PDF allowed")
Else
Dim _CurRootFolder As String = PortalSettings.HomeDirectoryMapPath
_CurRootFolder = _CurRootFolder + "resume\"
WriteToFile(_CurRootFolder + strFilename, myData)
End If
End If
End If
End Sub
Private Sub WriteToFile(ByVal strPath As String, ByRef Buffer As Byte())
Dim newFile As New FileStream(strPath, FileMode.Create)
newFile.Write(Buffer, 0, Buffer.Length)
newFile.Close()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If HasEditPermissions(ModuleId, TabId) Then
' End If
Try
If Not PortalSecurity.IsInRole("Registered Users") AndAlso Not PortalSecurity.IsInRole("Administrators") Then
Me.FormView1.Visible = True
AddItemButton.Visible = False
Else
Me.FormView1.Visible = True
AddItemButton.Visible = False
End If
Catch exc As Exception
'Module failed to load
Exceptions.ProcessModuleLoadException(Me, exc)
End Try
End If
'If HasEditPermissions(ModuleId, TabId) Then
'Else
' AddItemButton.Enabled = False
' lblResume.Visible = Falsem
' AddItemButton.Text = "برای ارسال رزومه باید ابتدا در سایت ثبت نام کنید و یا از قسمت ورود وارد سایت شوید"
' End If
End Sub
Protected Sub SetModuleID(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ResumeDataSource.Selecting
e.InputParameters("ModuleId") = ModuleId.ToString
End Sub
Protected Sub InsertingItem(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting
Dim ctrl As Control = FormView1.FindControl("chkImg")
If (DirectCast(ctrl, CheckBox).Checked = True) Then
FtpImage()
e.Values.Item("FileName") = SelectedFileName
End If
Dim ctrl2 As Control = FormView1.FindControl("ddGender")
Dim sex As String = DirectCast(ctrl2, DropDownList).SelectedValue
e.Values.Item("gender") = sex
e.Values.Item("ModuleId") = ModuleId.ToString()
End Sub
Protected Sub AddItemButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddItemButton.Click
End Sub
Public Function getMailBody(ByVal resume1 As ResumeInfo) As String
Dim mailbody As String = "
" + "رزومه " + resume1.FullName + " ارسال شد" + "
"
Dim murl = ""
If (Not String.IsNullOrEmpty(resume1.FileName.Trim())) Then
murl = "http://www.indonya.com/portals/0/resume/" + resume1.FileName
mailbody = mailbody + "فایل رزومه
"
murl = " آدرس فایل رزومه: " + "
" + murl + ""
Else
murl = ""
mailbody = mailbody + "
" + "فایلی به عنوان رزومه ارسال نشده است "
End If
Dim jdate As New JalaliDate()
Return mailbody + murl + "
تاریخ ارسال: " + jdate.getDateJ() + "
"
End Function
Protected Sub InsertItemButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
If Not PortalSecurity.IsInRole("Registered Users") AndAlso Not PortalSecurity.IsInRole("Administrators") Then
Me.FormView1.Visible = False
AddItemButton.Visible = True
lblResume.Visible = False
'Dim ctrl As Control = FormView1.FindControl("CaptchaControl1")
'If (DirectCast(ctrl, PIP.Modules.WebControlCaptcha.CaptchaControl).isTypesCorrect()) Then
'SendMailToAddress("ali.norouzitafreshhi@yahoo.com", "رزومه جدیدی ارسال شد", "رزومه جدیدی ارسال شد
")
' AddItemButton.Text = "رزومه شما با موفقیت ارسال شد پس از بررسی در اسرع وقت با شما تماس گرفته می شود.در صورت تمایل متوانید با کلیک برروی این لینک رزومه دیگری ارسال کنید"
Else
Me.FormView1.Visible = False
AddItemButton.Visible = True
lblResume.Visible = False
End If
'AddItemButton.Text = "کد وارد شده صحیح نیست باید کدی که در تصویر وجود دارد را وارد نمایید برای ارسال مجدد کلیک نمایید"
Catch exc As Exception
'Module failed to load
Exceptions.ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub InsertCancelButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Not PortalSecurity.IsInRole("Registered Users") AndAlso Not PortalSecurity.IsInRole("Administrators") Then
Me.FormView1.Visible = False
Else
Me.FormView1.Visible = False
End If
End Sub
Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles FormView1.ItemInserted
Dim resume1 As ResumeInfo = resumeCtrlr.GetLatestResume()
'MailHelper.SendMailMessage("ali.norouzitafreshi@yahoo.com", "info@indonya.com", " رزومه " + resume1.FullName + " ارسال شد ", getMailBody(resume1))
'MailHelper.SendMailMessage("Mailer@indonya.ir", "job@indonya.ir", " رزومه " + resume1.FullName + " Send", getMailBody(resume1))
End Sub
End Class
End Namespace