View Full Version : فرستادن یک فایل به ایمیل مورد نظر با vb
iranboy
شنبه 18 بهمن 1382, 10:45 صبح
سلام
با چه کدی میشه برنامه ای ساخت که از کامپیوتر اجرا کننده برنامه ما فایلی (مثلا c:/o.txt) را به ایمیلی فرستاد .
Best Programmer
شنبه 18 بهمن 1382, 11:32 صبح
این کد اگر میخواهی از ابزارهای ویندوز استفاده کنی خوب است.
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
ShellExecute hwnd, "open", "mailto:vbcode@vbcode.com", vbNullString, vbNullString, SW_SHOW
Best Programmer
شنبه 18 بهمن 1382, 11:35 صبح
اینم برای حالتی که میخواهی خودت کنترل داشته باشی.
Private Sub SendEmail_Click()
' Geocel DevMailer 1.0
' Visual Basic Usage Example
' (c) 1999, Geocel International, Inc.
'
' - DevMailer can be found at:
' - http://www.geoce.com/devmailer/
' Create DevMailer Object
Set Mailer = CreateObject("Geocel.Mailer")
' Add first SMTP server
Mailer.AddServer DMTestForm.Server_Address, 25
' Set Sender Information
Mailer.FromAddress = DMTestForm.From_Address
Mailer.FromName = "Devmailer Test"
' Add a recipient to the message
Mailer.AddRecipient DMTestForm.To_Address, ""
' Set the Subject and Body
Mailer.Subject = "Welcome to DevMailer"
Mailer.Body = DMTestForm.Message_Body & vbCrLf
' Send Email - Perform Error Checking
bSuccess = Mailer.Send()
If bSuccess = False Then
If Mailer.Queued = False Then
MsgBox ("Could not send message..queueing failed!")
Else
MsgBox ("Could not send message..queued instead!")
End If
Else
MsgBox ("Message Sent Successfully!")
End If
End Sub
الهام تفریشی
شنبه 18 بهمن 1382, 12:26 عصر
Public Function send_mail(sendto As String, subject As String, _
text As String) As Boolean
'Add The MAPI Components and
'add a MAPI Session and MAPI mail control to your form
On Error GoTo ErrHandler
With MAPISession1
.DownLoadMail = False
.LogonUI = True
.SignOn
.NewSession = True
MAPIMessages1.SessionID = .SessionID
End With
With MAPIMessages1
.Compose
.RecipAddress = sendto
.AddressResolveUI = True
.ResolveName
.MsgSubject = subject
.MsgNoteText = text
.Send False
End With
sendmail = True
ErrHandler:
End Function
ساران سافت
شنبه 18 بهمن 1382, 17:40 عصر
هیچ کدوم از این دو کد کار نمی کنند چرا؟ :roll: :oops:
سعید قدیری مقدم
چهارشنبه 06 اسفند 1382, 11:45 صبح
این کد ها کار نمیکنه چون object مورد احتاج رو دوستان برای دانلود نزاشتن
برای این منظور به این سایت سر بزن
http://www.geocel.com/devmailer/examples.htm
houshang.karami
شنبه 29 مرداد 1384, 12:07 عصر
با سلام این object GeoCel DevMailerپس از 90 روز از کار می افتد(evalution copy)
houshang.karami
شنبه 29 مرداد 1384, 14:52 عصر
با سلام این کد با MAPISESSION خودOUTLOOK نوشته شده است چون به هر صورت ما برای فرستادن ایمیل نیاز به Mailserver داریم من در پروژه ای که داشتم از Mailserver داخلی و OutLook استفاده می کردم
این بنظرم مشکل شما را حل می کند امیدوارم مفید واقع شود
Private Function Sendemail(msg)
With MAPISession1
.LogonUI = True
.UserName = strUserName
.Password = strPassword
.SignOn
End With
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.MsgNoteText = msg
.RecipAddress = addy
.MsgSubject = "Error In Copiying File"
'.AttachmentPathName = "c:\1.txt"
.ResolveName
.Send
End With
With MAPISession1
.SignOff
End With
End Function
houshang.karami
شنبه 29 مرداد 1384, 15:00 عصر
با سلام
البته دوست عزیز آقای تفرشی نیز از راه MapiSession رفته است
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.