PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Displaying Email and MsgBox simultaneously

Reply

Displaying Email and MsgBox simultaneously

 
Thread Tools Rate Thread
Old 06-03-2005, 03:07 PM   #1
Fercat
Guest
 
Posts: n/a
Default Displaying Email and MsgBox simultaneously


Hi,

Lurking trough newsgroups, I wrote an useful macro that, starting from an
Excel Db, permits me to email-merge with attachments:

Sub SendMail()

Dim Riga As Integer
Riga = InputBox("Inserisci la riga del Negozio dal quale vuoi iniziare
l'Email-Merge")
Range("A" & Riga).Select

Do Until ActiveCell.Value = ""
Dim ol As Object
Dim mailitem As Object

Set ol = CreateObject("Outlook.Application")
Set mailitem = ol.CreateItem(olMailItem)

With mailitem
.To = ActiveCell.Value
.CC = ActiveCell.Offset(0, 1).Value
.Subject = "Report number " & ActiveCell.Offset(0, 2).Value
.Body = "Buongiorno... "
.Attachments.Add (ActiveCell.Offset(0, 5).Value)
.Display
End With

SendKeys "%s"

Set ol = Nothing
Set mailitem = Nothing

ActiveCell.Offset(1, 0).Select
Loop

End Sub

Everything works really fine. Anyway, I'd like to add a Msgbox opening
simultaneously with the Displaying of the Email.
This should be a Yes-No MsgBox saying "Check the message. Do you want to
send it?"
I think it's a possible task but I don't know the code that allows it.

Can anybody help me?

Thanks to all!!!



  Reply With Quote
Old 06-03-2005, 07:02 PM   #2
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Displaying Email and MsgBox simultaneously

.Attachments.Add (ActiveCell.Offset(0, 5).Value)
.Display
intYes = MsgBox("your text", vbYesNo + vbQuestion)
If intYes Then
.Send
End If

Note that the .Send command will trigger a security prompt. See
http://www.outlookcode.com/d/sec.htm

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Fercat" <fercat@libero.it> wrote in message
news:J0FWd.7688$WC1.6341@tornado.fastwebnet.it...
> Hi,
>
> Lurking trough newsgroups, I wrote an useful macro that, starting from an
> Excel Db, permits me to email-merge with attachments:
>
> Sub SendMail()
>
> Dim Riga As Integer
> Riga = InputBox("Inserisci la riga del Negozio dal quale vuoi iniziare
> l'Email-Merge")
> Range("A" & Riga).Select
>
> Do Until ActiveCell.Value = ""
> Dim ol As Object
> Dim mailitem As Object
>
> Set ol = CreateObject("Outlook.Application")
> Set mailitem = ol.CreateItem(olMailItem)
>
> With mailitem
> .To = ActiveCell.Value
> .CC = ActiveCell.Offset(0, 1).Value
> .Subject = "Report number " & ActiveCell.Offset(0, 2).Value
> .Body = "Buongiorno... "
> .Attachments.Add (ActiveCell.Offset(0, 5).Value)
> .Display
> End With
>
> SendKeys "%s"
>
> Set ol = Nothing
> Set mailitem = Nothing
>
> ActiveCell.Offset(1, 0).Select
> Loop
>
> End Sub
>
> Everything works really fine. Anyway, I'd like to add a Msgbox opening
> simultaneously with the Displaying of the Email.
> This should be a Yes-No MsgBox saying "Check the message. Do you want to
> send it?"
> I think it's a possible task but I don't know the code that allows it.
>
> Can anybody help me?
>
> Thanks to all!!!
>
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off