PDA

View Full Version : ارسال ایمیل بدون استفاده از کنترل Winsock



bluemilad
شنبه 21 شهریور 1383, 12:26 عصر
اگه میشه یه سورسی رو برام بذارید که با استفاده از اون بشه بدون استفاده از کنترل Winsock به تمامی سرویس ها مثل یاهو هات میل ایمیل ارسال نمود. خیلی ممنون از کمکتون.

HoneySaberi
شنبه 21 شهریور 1383, 13:23 عصر
دوست عزیزم سلام.
من کمی Socket Programming کار کردم و کمی در مورد برنامه نویسی شبکه میدونم.
راستش فکر نمی کنم بدون استفاده مستقیم یا غیر مستقیم از امکانات سوکتی ویندوز بتونی با VB ایمیل ارسال کنی.
اما اگر مشکل استفاده مستقیم از APIهای سوکتی، میتونی از یک ActivX مثل Socket Wrench استفاده کنی. اگر مشکل همینه سری به اینجا بزن:
http://www.catalyst.com/download/wrench.html

bluemilad
شنبه 21 شهریور 1383, 21:45 عصر
فکر کنم بشه با MAPI یه کارایی کرد. ولی خوب نمی‌دونم چه جوری. مشکل من اینکه من می‌خوام از دست ActiveX راحت بشم.

MM_Mofidi
دوشنبه 23 شهریور 1383, 03:06 صبح
چندین راه مختلف داره
اما به نظر من اگه میتونی همه کنترل را به ویندوز منتقل کن و توسط برنامه پیش فرض مدیریت میل اینکار را انجام بده با دستور Mailto:name@domain.XXX
(البته اگه نمیخواهی کار خواصی روش انجام بدهی)
یا از اینها استفاده کن
MAPI


'NONE
'Put 'Microsoft shell controls and automation' to references

Dim oShell As New Shell
Dim oFolder As Folder
Dim oFolderItem As FolderItem

Set oFolder = oShell.NameSpace("C:\")
Set oFolderItem = oFolder.Items.Item("AUTOEXEC.BAT")

oFolderItem.InvokeVerb "&Copy"

Set oFolder = oShell.NameSpace(9)
Set oFolderItem = oFolder.Items.Item("Mail Recipient.MAPIMail")

oFolderItem.InvokeVerb "&Paste"

Launch the Windows Mail Control panel GUI



Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Dim strSysDirPath As String
Dim vRetval As Double

'Setup the string to receive the name of the system directory
strSysDirPath = String$(145, Chr$(0))
strSysDirPath = Left$(strSysDirPath, GetWindowsDirectory(strSysDirPath, Len(strSysDirPath)))

'Run the Mail Control Panel
vRetval = Shell(strSysDirPath & "\control.exe mlcfg32.cpl", 1)

'Do the rest of your work here. Note: Most developers will
'likely want to pause their application here until returning from
'the Control Panel
MsgBox vRetval




'just select SMTP control from Components ( under project menu (visual basic))
************************************************** **********************
With SMTP 'name for control
.Server = outgoingserver 'Outgoing server name or IP address

.MailFrom = mailFrom 'Sender mail address

.SendTo = mailto 'to whom you want to send mail

.MessageSubject ='Subject of message

.MessageText = mailtext 'mail text

.Attachements.Add attachmentpath 'if you want ot attach any file just give the path here

DoEvents

.Connect

End With

************************************************** ************




'No declarations, add to project references:
'Microsoft Outlook 9.0 Object Library
'Microsoft Data Formatting Object Library 6.0(SP4)
Public Sub envoi()
'programmation de l'envoi d'un e-mail
Dim objOutlook As Outlook.Application
Dim objSession As Outlook.NameSpace
Dim objMessage As Outlook.MailItem 'Object
Dim objRecipient As Object
Dim fichier_joint As String
Dim adresse As String

fichier_joint = "c:\test.txt"
adresse = "toto@hotmail.com"

Set objOutlook = CreateObject("Outlook.Application")
Set objSession = objOutlook.GetNamespace("MAPI")
Set objMessage = objOutlook.CreateItem(olMailItem)
Set objRecipient = objSession.CreateRecipient(adresse)

objSession.Logon
objMessage.Recipients.Add (objRecipient)
objMessage.Subject = "Test"
objMessage.Body = "This is a Test"
objMessage.Attachments.Add (fichier_joint)
objMessage.Send
' objMessage.Display
MsgBox "Message sent successfully!"
Set objRecipient = Nothing
objSession.Logoff
End Sub

این همونی که گفتم


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


فکر کنم در 98 جواب ندهد


Shell("start whoever@whatever.ANYTHING", vbNormalFocus)