[Migrated content. Thread originally posted on 19 August 2008]
Hi,Hopefully someone can help me here as I'm completely lost.
I usually have a crack at these now since Gisle's course, and usually can get somewhere.
But not in this case.
It seems that all I learned on the course has been thrown out the window?
OK, a colleague in work is using this to bypass the outlook security questions and found sample VB code which is working and attached.
I've attached the defination file I created yesterday.
Any pointers as to how I convert would be grately received.
i.e. when using outlook I do
Create Application Of Outlook Handle In Outlook-HandleBut this thing is different?
Thanks,
Shaun
Public Function SendMessage() As Boolean
' The SendMessage() function reads user entered values and
' actually sends the message.
On Error Resume Next
Dim strRecip As String
Dim strRecipCC As String
Dim strSubject As String
Dim strMsg As String
Dim strAttachment As String
Dim objSafeMail, oItem
strSubject = lclMailSubject
strRecip = lclEmailAddress
strMsg = " " lclTemplateMsg
strAttachment = lclDiskFileName
If lclEmailAddressNo2 <> "" Then
strRecipCC = lclEmailAddressNo2
End If
' Any amount of validation could be done at this point, but
' at a minimum, you need to verify that the user supplied an
' Email address for a recipient.
If Len(strRecip) = 0 Then
strMsg = "You must designate a recipient."
MsgBox strMsg, vbExclamation, "Error"
Exit Function
End If
' Assume success
fSuccess = True
' Here's where the real Outlook Automation takes place
If fSuccess = True Then
'Set mItem = mOutlookApp.CreateItem(olMailItem)
Set objSafeMail = CreateObject("Redemption.SafeMailItem")
Set oItem = Application.CreateItem(0)
objSafeMail.Item = oItem
'mItem.Recipients.Add strRecip
'mItem.SentOnBehalfOfName = "kpatterson@sysco-software.com"
'mItem.ReplyRecipients.Add ("kpatterson@sysco-software.com")
objSafeMail.Recipients.Add strRecip
'objSafeMail.SentOnBehalfOfName = "kpatterson@sysco-software.com"
'objSafeMail.ReplyRecipients.Add ("kpatterson@sysco-software.com")
If strRecipCC <> "" Then
'mItem.CC = strRecipCC
objSafeMail.CC = strRecipCC
End If
'mItem.Subject = strSubject
'mItem.Body = strMsg
objSafeMail.Subject = strSubject
objSafeMail.Body = strMsg
' This code allows for 1 attachment, but with slight
' modification, you could provide for multiple files.
If Len(strAttachment) > 0 Then
'mItem.Attachments.Add strAttachment
objSafeMail.Attachments.Add strAttachment
End If
If lclEmailDirect = False Then
'mItem.Save
objSafeMail.Save
Else
'mItem.Send
objSafeMail.Send
End If
End If
If Err.Number > 0 Then fSuccess = False
SendMessage = fSuccess
End Function



