?
Solved

sending mails using outlook object

Posted on 2003-11-27
3
Medium Priority
?
554 Views
Last Modified: 2007-12-19
i am developing an application to send mails using the outlook object. since i was getting a security alert everytime the mails were sent, i downloaded and used the Redemption.dll library and safe mail objects.

i have pasted the code below:

Set myItem = CreateObject("Redemption.SafeMailItem")
Set oitem = oOutlookApplication.CreateItem(olMailItem)
strToAddress = olInboxItems_ItemAdd(myITems(intcnt))
myItem.Item = oitem
myItem.Recipients.Add (strToAddress)
myItem.Recipients.ResolveAll
myItem.Subject = "test"
myItem.Body = "this is a test"

the problem with this code is that the mails are sent to the draft folder and not the outbox. i found out why this is happening. it is because there is no email address in "sent by". i am not able to assign a sent by email address using redemption. so what is the solution to this?
0
Comment
Question by:RTKVSNL
3 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 9831424
Try this see if this solve your problem:

Private Sub Command4_Click()
    Dim iOutlook As Outlook.Application
    Dim myApp As Outlook.MailItem
    Set iOutlook = New Outlook.Application
    Set myApp = iOutlook.CreateItem(olMailItem)
    temp = "username"
    txtMessage = "Hello World Again!"
    AttachFile = "C:\test\test.gif"
    myApp.To = "receiver@domain.com"
    myApp.Subject = "Hello World!"
    myApp.Attachments.Add AttachFile
    myApp.Body = "Hi " & temp & vbCrLf & vbCrLf & txtMessage
    myApp.Send
    Do While iOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox).Items.Count <> 0
        DoEvents
    Loop
    MsgBox "Successfully Sent", vbInformation, "Email Sent"
End Sub
0
 

Author Comment

by:RTKVSNL
ID: 9831520
this cannot solve my problem because outlook has a security patch that needs a response from the user every time a mail will be sent. that is why i am using the redemption object.
0
 
LVL 7

Accepted Solution

by:
wsteegmans earned 500 total points
ID: 9831878
Take a look at these links:
- http://www.dimastr.com/redemption/
- http://www.outlookforum.com/t36290-s 

Included, some code that creates a Auto Reply for every new message in the Inbox ...
This example uses Outlook Redemption

Sub RedemptionMail()

Dim oOutlook As Outlook.Application
Dim oFldr As Outlook.MAPIFolder
Dim oMsg, oReply As Redemption.SafeMailItem
Dim mSender As Redemption.AddressEntry
Dim mSendQue As Redemption.MAPIUtils
Dim oMessage As Object
Dim oNs As Outlook.NameSpace
Dim mSubject, mFrom, mBody As String

Set oOutlook = New Outlook.Application
Set oNs = oOutlook.GetNamespace("MAPI")
Set oFldr = oNs.PickFolder
Set oMsg = CreateObject("Redemption.SafeMailItem")
Set oReply = CreateObject("Redemption.SafeMailItem")
Set mSendQue = CreateObject("Redemption.MAPIUtils")

oMsg.AuthKey = "*******"
oReply.AuthKey = "*******"
mSendQue.AuthKey = "*******"

For Each oMessage In oFldr.Items
    oMsg.Item = oMessage
    oReply.Item = oMessage.Reply ' •¤• Create reply to original message •¤•
    oReply.Body = "Testing Auto Reply"
    oReply.Send
    mSubject = oMsg 'Get e-mail subject
    mFrom = oMsg.SenderName 'Get e-mail SendersName
    Set mSender = oMsg.Sender
    mFromAdd = mSender.Address
    mBody = oMsg.Body 'Get e-mail message body
Next oMessage

mSendQue.DeliverNow

Set oOutlook = Nothing
Set oNs = Nothing
Set oFldr = Nothing
Set oMsg = Nothing
Set oReply = Nothing
Set mSender = Nothing
Set mSendQue = Nothing

End Sub
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question